1
我在使用listqueryqueryquery過濾組合框。過濾時一切都很好,但我面臨着一個問題,如:在extjs中使用onLoad()自動選擇問題
當我們在組合框中輸入所需的字符來過濾它們被自動選擇..所以當我們要輸入新的字符,我們必須按右側的箭頭刪除選擇或其他字符正在被刪除...請幫助爲什麼這種行爲。
代碼:
xtype: 'combo',
fieldLabel: 'Label',
anchor: '100%',
enableKeyEvents: true,
allowBlank: false,
displayField: 'value',
store: 'level1Store',
lazyInit: false,
mode: 'local',
forceSelection: true,
disableKeyFilter: true,
editable: true,
triggerAction: 'all',
valueField: 'key',
name: 1,
ref: 'combo1',
id: 'field1'
聽者代碼進行過濾:
Ext.getCmp('field1').addListener({
beforequery: function (e) {
if (e.query && e.query.indexOf('?') != -1) {
e.cancel = true;
var query = new RegExp(String.format('^{0}', e.query.replace(/\?/g, '[A-Za-z0-9]')));
this.onLoad();
this.store.clearFilter(true);
this.store.filter(this.displayField, query);
}
}
});