|
|
|
/**
|
|
|
|
* 选择字段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",
|
|
|
|
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",
|
|
|
|
element: this,
|
|
|
|
height: o.height,
|
|
|
|
readonly: o.readonly,
|
|
|
|
text: this._digest(o.value, o.items)
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_digest: function(vals, items){
|
|
|
|
var o = this.options;
|
|
|
|
vals = BI.isArray(vals) ? vals : [vals];
|
|
|
|
var result = [];
|
|
|
|
var formatItems = BI.Tree.transformToArrayFormat(items);
|
|
|
|
BI.each(formatItems, function (i, item) {
|
|
|
|
if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) {
|
|
|
|
result.push(item.text || item.value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (result.length > 0) {
|
|
|
|
return result.join(",");
|
|
|
|
} else {
|
|
|
|
return o.text;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setValue: function (vals) {
|
|
|
|
this.trigger.setText(this._digest(vals, this.options.items));
|
|
|
|
},
|
|
|
|
|
|
|
|
populate: function (items) {
|
|
|
|
this.options.items = items;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
BI.shortcut("bi.select_text_trigger", BI.SelectTextTrigger);
|