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.

77 lines
2.1 KiB

/**
* @class BI.SingleTreeCombo
* @extends BI.Widget
*/
BI.SingleTreeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-single-tree-combo",
trigger: {},
7 years ago
height: 24,
text: "",
items: [],
value: ""
});
},
_init: function () {
BI.SingleTreeCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
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({
7 years ago
type: "bi.single_level_tree",
items: o.items,
value: o.value
});
this.combo = BI.createWidget({
type: "bi.combo",
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 = "SingleTreeCombo.EVENT_CHANGE";
BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
8 years ago
BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);