fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

107 lines
3.1 KiB

/**
*
*
* 查看已选弹出层的展示面板
* @class BI.DisplaySelectedList
* @extends BI.Widget
*/
BI.DisplaySelectedList = BI.inherit(BI.Pane, {
constants: {
height: 24,
lgap: 10
},
_defaultConfig: function () {
return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-display-list",
itemsCreator: BI.emptyFn,
items: []
});
},
_init: function () {
BI.DisplaySelectedList.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
this.hasNext = false;
var cacheItems = [];
this.button_group = BI.createWidget({
type: "bi.list_pane",
element: this,
el: {
type: "bi.loader",
isDefaultInit: false,
logic: {
dynamic: true,
scrolly: true
},
items: this._createItems(opts.items),
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
layouts: [{
type: "bi.vertical",
lgap: 10
}]
},
itemsCreator: function (options, callback) {
if (options.times === 1) {
cacheItems = [];
}
if (cacheItems.length > 0) {
var renderedItems = cacheItems.slice(0, 100);
cacheItems = cacheItems.slice(100);
self.hasNext = true;
if (cacheItems.length === 0) {
self.hasNext = false;
}
callback(self._createItems(renderedItems));
return;
}
opts.itemsCreator(options, function (ob) {
self.hasNext = !!ob.hasNext;
var firstItemsCount = 100 + ob.items.length % 100;
if (ob.items.length > 100) {
cacheItems = ob.items.slice(100 + ob.items.length % 100);
self.hasNext = true;
}
callback(self._createItems(ob.items.slice(0, firstItemsCount)));
});
},
hasNext: function () {
return self.hasNext;
}
});
},
_createItems: function (items) {
return BI.createItems(items, {
type: "bi.icon_text_item",
cls: "cursor-default check-font icon-size-12 display-list-item bi-tips",
once: true,
invalid: true,
selected: true,
height: this.constants.height,
logic: {
dynamic: true
}
});
},
empty: function () {
this.button_group.empty();
},
populate: function (items) {
if (arguments.length === 0) {
this.button_group.populate();
} else {
this.button_group.populate(this._createItems(items));
}
}
});
BI.shortcut("bi.display_selected_list", BI.DisplaySelectedList);