ExtJs combobox 自定义过滤-模糊过滤
ExtJs combobox 自定义过滤-模糊过滤
2011年09月01日
ExtJs combobox 自定义过滤-模糊过滤.
其实是复制ComboBox的doQuery方法体,进行修改.. this.myCombo.on('beforequery',function(qe){ var combo = qe.combo; //q is the text that user inputed. var q = qe.query; forceAll = qe.forceAll; if(forceAll === true || (q.length >= combo.minChars)){ if(combo.lastQuery !== q){ combo.lastQuery = q; if(combo.mode == 'local'){ combo.selectedIndex = -1; if(forceAll){ combo.store.clearFilter(); }else{ combo.store.filterBy(function(record,id){ var text = record.get(combo.displayField); //在这里写自己的过滤代码 return (text.indexOf(q)!=-1); }); } combo.onLoad(); }else{ combo.store.baseParams[combo.queryParam] = q; combo.store.load({ params: combo.getParams(q) }); combo.expand(); } }else{ combo.selectedIndex = -1; combo.onLoad(); } } return false; });