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.

111 lines
3.2 KiB

8 years ago
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
_createItems: function () {
7 years ago
var items = BI.map(BI.range(1000), function (i) {
return {
type: "demo.virtual_group_item",
7 years ago
value: i,
7 years ago
key: i + 1
7 years ago
};
8 years ago
});
return items;
},
render: function () {
var self = this;
7 years ago
var buttonGroupItems = self._createItems();
var virtualGroupItems = self._createItems();
8 years ago
return {
type: "bi.vertical",
vgap: 20,
items: [{
7 years ago
type: "bi.label",
cls: "layout-bg5",
height: 50,
7 years ago
text: "共1000个元素,演示button_group和virtual_group每次删除第一个元素,打开控制台看输出"
7 years ago
}, {
7 years ago
type: "bi.button_group",
width: 500,
height: 300,
ref: function () {
self.buttonGroup = this;
},
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
layouts: [{
type: "bi.vertical"
}],
items: this._createItems()
}, {
type: "bi.button",
text: "演示button_group的刷新",
handler: function () {
7 years ago
buttonGroupItems.shift();
self.buttonGroup.populate(BI.deepClone(buttonGroupItems));
7 years ago
}
}, {
8 years ago
type: "bi.virtual_group",
8 years ago
width: 500,
8 years ago
height: 300,
ref: function () {
7 years ago
self.virtualGroup = this;
8 years ago
},
chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
layouts: [{
type: "bi.vertical"
}],
items: this._createItems()
}, {
type: "bi.button",
7 years ago
text: "演示virtual_group的刷新",
8 years ago
handler: function () {
7 years ago
virtualGroupItems.shift();
self.virtualGroup.populate(BI.deepClone(virtualGroupItems));
8 years ago
}
}]
7 years ago
};
8 years ago
}
});
8 years ago
BI.shortcut("demo.virtual_group", Demo.Func);
8 years ago
Demo.Item = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-item",
height: 30
},
render: function () {
7 years ago
var self = this, o = this.options;
8 years ago
return {
type: "bi.label",
ref: function () {
self.label = this;
},
height: this.options.height,
7 years ago
text: "key:" + o.key + ",随机数" + BI.UUID()
7 years ago
};
8 years ago
},
shouldUpdate: function (nextProps) {
var o = this.options;
return o.type !== nextProps.type || o.key !== nextProps.key || o.value !== nextProps.value;
},
8 years ago
update: function (item) {
this.label.setText(item.value);
console.log("更新了一项");
7 years ago
return true;// 返回是不是更新成功
8 years ago
},
created: function () {
console.log("创建了一项");
8 years ago
},
8 years ago
destroyed: function () {
8 years ago
console.log("删除了一项");
8 years ago
}
});
8 years ago
BI.shortcut("demo.virtual_group_item", Demo.Item);