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.

56 lines
1.6 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), {
baseCls: "bi-select-text-trigger bi-border bi-focus-shadow",
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,
7 years ago
height: o.height,
readonly: o.readonly,
text: this._digest(o.value, o.items)
8 years ago
});
},
7 years ago
_digest: function(vals, items){
8 years ago
var o = this.options;
vals = BI.isArray(vals) ? vals : [vals];
var result = [];
7 years ago
var formatItems = BI.Tree.transformToArrayFormat(items);
BI.each(formatItems, function (i, item) {
if (BI.deepContains(vals, item.value) && !BI.contains(result, item.text || item.value)) {
8 years ago
result.push(item.text || item.value);
}
});
if (result.length > 0) {
7 years ago
return result.join(",");
8 years ago
} else {
7 years ago
return o.text;
8 years ago
}
},
7 years ago
setValue: function (vals) {
this.trigger.setText(this._digest(vals, this.options.items));
7 years ago
},
8 years ago
populate: function (items) {
this.options.items = items;
}
});
8 years ago
BI.shortcut("bi.select_text_trigger", BI.SelectTextTrigger);