我正在使用 ExtJS 4 并寻找一种可以从组合的下拉列表中隐藏当前选定值的方法?
因此,代替这个(当前在组合框中选择“阿拉斯加”):
我希望值列表如下所示:
就我而言,组合框是不可编辑(即您不能输入任意值),我认为两次显示所选值没有多大意义:一次在输入字段中,一次在下拉列表中。我已经看到了所选内容,我希望下拉列表只显示我other我可以选择的选项。
到目前为止,我还没有看到一个简单的方法来做到这一点。可能最好的起点是过滤组合框存储,但组合框使用自己的过滤器来实现实时搜索功能。
有人考虑过这个问题吗?我是在尝试做一些奇怪的事情吗?
我很惊讶我找不到任何相关主题。
我认为你在这里没有太多选择......也许你可以这样做:
Ext.define('Your.company.Combo', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.specialcombo',
/**
* @cfg {boolean} hideActive
* True to hide any selected record. Defaults to <tt>true</tt>.
*/
hideActive: true,
/**
* @private {Ext.data.Model[]} hideActive
* A Array of selected records.
*/
initComponent: function () {
this.selectedRecords = [];
this.callParent(arguments);
this.on('select', this.onSelectionChange, this);
},
/**
* @private onChangeSelection
* eventhandler selections
*/
onSelectionChange: function (me, recs) {
if(!me.hideActive)
return;
// write the current selected back to the store (you need to suspend autoSync if active)
me.store.add(me.selectedRecords);
// set the selected as new recordlist
me.selectedRecords = recs;
// remove the selected from the store
me.store.remove(recs);
}
});
该示例完全未经测试。但由于商店主要绑定到 BoundList,而 BoundList 没有直接连接到文本字段,所以这应该可以工作。你在这里做了某种缓存。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)