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.

53 lines
1.5 KiB

8 years ago
/**
* 选择字段trigger
*
* Created by GUY on 2015/9/15.
* @class BI.SelectTextTrigger
* @extends BI.Trigger
*/
BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.SelectTextTrigger.superclass._defaultConfig.apply(this, arguments), {
8 years ago
baseCls: "bi-select-text-trigger bi-border",
8 years ago
height: 24
});
},
_init: function () {
this.options.height -= 2;
BI.SelectTextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.text_trigger",
8 years ago
element: this,
8 years ago
height: o.height
});
7 years ago
if (BI.isKey(o.text)) {
this.setValue(o.text);
}
8 years ago
},
setValue: function (vals) {
var o = this.options;
vals = BI.isArray(vals) ? vals : [vals];
var result = [];
var items = BI.Tree.transformToArrayFormat(this.options.items);
BI.each(items, function (i, item) {
if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) {
8 years ago
result.push(item.text || item.value);
}
});
if (result.length > 0) {
this.trigger.setText(result.join(","));
} else {
this.trigger.setText(o.text);
}
},
populate: function (items) {
this.options.items = items;
}
});
8 years ago
BI.shortcut("bi.select_text_trigger", BI.SelectTextTrigger);