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.

80 lines
2.3 KiB

/**
* @class BI.SingleTreeCombo
* @extends BI.Widget
*/
BI.SingleTreeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function (config) {
return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-tree-combo bi-border-radius " + (config.simple ? "bi-border-bottom" : "bi-border"),
trigger: {},
8 years ago
height: 24,
text: "",
items: [],
7 years ago
value: "",
});
},
_init: function () {
var self = this, o = this.options;
o.height -= 2;
BI.isNumeric(o.width) && (o.width -= 2);
BI.SingleTreeCombo.superclass._init.apply(this, arguments);
this.trigger = BI.createWidget(BI.extend({
type: "bi.single_tree_trigger",
text: o.text,
height: o.height,
items: o.items,
value: o.value
}, o.trigger));
this.popup = BI.createWidget({
8 years ago
type: "bi.single_level_tree",
items: o.items,
value: o.value
});
this.combo = BI.createWidget({
type: "bi.combo",
7 years ago
container: o.container,
element: this,
adjustLength: 2,
el: this.trigger,
popup: {
el: this.popup
}
});
this.combo.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments);
});
this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE);
});
},
populate: function (items) {
this.combo.populate(items);
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.trigger.setValue(v);
this.popup.setValue(v);
},
getValue: function () {
return this.popup.getValue();
}
});
BI.SingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
8 years ago
BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);