Combo 过滤

Ext.onReady(function() { var cbo = new Ext.form.ComboBox({ //typeAhead: true, triggerAction: 'all', lazyRender: true, mode: 'local', store: new Ext.data.ArrayStore({ fields: ['no', 'id', 'text'], //根据自己的需要设置 data: [['1001', 'ml', '目录'], ['1002', 'mls', '目录数'], ['2001', 'fc', '房产'], ['2002', 'szh', '数字化'], ['2003', 'szhzx', '数字化中心'], ['2004', 'szhzxda', '数字化中心档案'], ['2005', 'szhzxda', '数字化中心答案'] ] }), valueField: 'no', displayField: 'text', queryDelay: 100, doQuery: function(q, forceAll) { q = Ext.isEmpty(q) ? '' : q; var qe = { query: q, forceAll: forceAll, combo: this, cancel: false }; if (this.fireEvent('beforequery', qe) === false || qe.cancel) { return false; } q = qe.query; forceAll = qe.forceAll; if (forceAll === true || (q.length >= this.minChars)) { if (this.lastQuery !== q) { this.lastQuery = q; if (this.mode == 'local') { //静态数据 this.selectedIndex = -1; if (forceAll) { this.store.clearFilter(); } else { this.store.filterBy(function(r) { if (r.get('no').indexOf(q) == 0 || r.get('id').indexOf(q) == 0 || r.get('text').indexOf(q) == 0) return true; return false }); //这个函数,字段要跟上面store中定义的字段相对应,函数根据自己需要修改。 } this.onLoad(); } else { //动态数据在此修改 this.store.baseParams[this.queryParam] = q; this.store.load({ params: this.getParams(q) }); this.expand(); } } else { this.selectedIndex = -1; this.onLoad(); } } } }); var f = new Ext.form.FormPanel({ renderTo: document.body, items: cbo, height: 100 }) }) 

你可能感兴趣的:(Combo 过滤)