[Common] ComboDataView: add groups for DataView, refactoring item template

This commit is contained in:
Julia Radzhabova 2021-12-02 23:42:54 +03:00
parent b304b01e9b
commit b217759f82

View file

@ -81,6 +81,7 @@ define([
this.style = this.options.style; this.style = this.options.style;
this.hint = this.options.hint; this.hint = this.options.hint;
this.store = this.options.store || new Common.UI.DataViewStore(); this.store = this.options.store || new Common.UI.DataViewStore();
this.groups = this.options.groups;
this.itemWidth = this.options.itemWidth; this.itemWidth = this.options.itemWidth;
this.itemHeight = this.options.itemHeight; this.itemHeight = this.options.itemHeight;
this.menuMaxHeight = this.options.menuMaxHeight; this.menuMaxHeight = this.options.menuMaxHeight;
@ -92,18 +93,19 @@ define([
this.needFillComboView = false; this.needFillComboView = false;
this.minWidth = this.options.minWidth; this.minWidth = this.options.minWidth;
this.delayRenderTips = this.options.delayRenderTips || false; this.delayRenderTips = this.options.delayRenderTips || false;
this.itemTemplate = this.options.itemTemplate || _.template([
this.fieldPicker = new Common.UI.DataView({
cls: 'field-picker',
allowScrollbar: false,
itemTemplate : _.template([
'<div class="style" id="<%= id %>">', '<div class="style" id="<%= id %>">',
'<img src="<%= imageUrl %>" width="' + this.itemWidth + '" height="' + this.itemHeight + '"/>', '<img src="<%= imageUrl %>" width="' + this.itemWidth + '" height="' + this.itemHeight + '"/>',
'<% if (typeof title !== "undefined") {%>', '<% if (typeof title !== "undefined") {%>',
'<span class="title"><%= title %></span>', '<span class="title"><%= title %></span>',
'<% } %>', '<% } %>',
'</div>' '</div>'
].join('')), ].join(''));
this.fieldPicker = new Common.UI.DataView({
cls: 'field-picker',
allowScrollbar: false,
itemTemplate : this.itemTemplate,
delayRenderTips: this.delayRenderTips delayRenderTips: this.delayRenderTips
}); });
@ -128,15 +130,9 @@ define([
restoreHeight: this.menuMaxHeight, restoreHeight: this.menuMaxHeight,
style: 'max-height: '+this.menuMaxHeight+'px;', style: 'max-height: '+this.menuMaxHeight+'px;',
enableKeyEvents: this.options.enableKeyEvents, enableKeyEvents: this.options.enableKeyEvents,
groups: this.groups,
store: this.store, store: this.store,
itemTemplate : _.template([ itemTemplate : this.itemTemplate,
'<div class="style" id="<%= id %>">',
'<img src="<%= imageUrl %>" width="' + this.itemWidth + '" height="' + this.itemHeight + '"/>',
'<% if (typeof title !== "undefined") {%>',
'<span class="title"><%= title %></span>',
'<% } %>',
'</div>'
].join('')),
delayRenderTips: this.delayRenderTips delayRenderTips: this.delayRenderTips
}); });