|
|
|
@ -22,24 +22,47 @@
|
|
|
|
|
var Widget = BI.inherit(BI.Widget, { |
|
|
|
|
render: function () { |
|
|
|
|
var self = this, o = this.options; |
|
|
|
|
var layout = o.layouts[0]; |
|
|
|
|
if (layout.scrollable) { |
|
|
|
|
this.element.css("overflow", "auto"); |
|
|
|
|
} |
|
|
|
|
if (layout.scrollx) { |
|
|
|
|
this.element.css("overflow-x", "auto"); |
|
|
|
|
} |
|
|
|
|
if (layout.scrolly) { |
|
|
|
|
this.element.css("overflow-y", "auto"); |
|
|
|
|
} |
|
|
|
|
this.populate(o.items); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_mountChildren: function () { |
|
|
|
|
var self = this, o = this.options; |
|
|
|
|
for (var key in this._children) { |
|
|
|
|
var child = this._children[key]; |
|
|
|
|
if (child.element !== self.element) { |
|
|
|
|
this.element.append(child.element); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
BI.Services.getService("swing.layout.service").layout(this.element, o.layouts[0]); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
populate: function (items) { |
|
|
|
|
var self = this, o = this.options; |
|
|
|
|
this.element.populate(BI.map(items, function (i, item) { |
|
|
|
|
return item.text; |
|
|
|
|
})) |
|
|
|
|
this.element.empty(); |
|
|
|
|
this._children = []; |
|
|
|
|
BI.each(items, function (i, item) { |
|
|
|
|
self._children.push(BI.createWidget(item)); |
|
|
|
|
}); |
|
|
|
|
this._mountChildren(); |
|
|
|
|
this.element.updateUI(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
BI.shortcut("swing.button_group", Widget); |
|
|
|
|
|
|
|
|
|
var Button = Java.type("com.tptj.tool.hg.fineui.swing.element.ListElement"); |
|
|
|
|
|
|
|
|
|
// 这里仅实现通过button_group来动态创建组件并能刷新的功能
|
|
|
|
|
BI.config("bi.button_group", function (config) { |
|
|
|
|
return BI.extend({}, config, { |
|
|
|
|
type: "swing.button_group", |
|
|
|
|
swingElement: Button |
|
|
|
|
return BI.extend({}, config,{ |
|
|
|
|
type: "swing.button_group" |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
}()); |
|
|
|
|