Ext JS 实现建议词模糊动态搜索功能

代码:

new Ext.form.ComboBox({ store: new Ext.data.JsonStore({ idProperty: 'VehicleNo', url: '../ajax/test.ashx, fields: ['VehicleNo', 'phoneNum'] }), id:'querynodesid', emptyText:'快速检索', hiddenName: 'VehicleNo', displayField: 'VehicleNo', valueField: 'VehicleNo', queryParam: 'VehicleNo', forceSelection: true, hideTrigger: true, queryDelay: 500, width:100, enableKeyEvents: true, minChars: 1, mode: 'remote', listeners: { 'select': { fn: function (combo, record, index) { var no = Ext.get("querynodesid").dom.value; findByKeyWordFiler2(no); } } } })

参数说明:

queryParam: 'VehicleNo',参数为输入的值 会以VehicleNo参数传入后台,可自定义;

test.ashx? 返回的参数格式为[{"VehicleNo":"00001","phoneNum":"000002"},{},{}];

'select' 为当选择某个数据的时候需要执行的回调;

这种方法适用数据量小的搜索,如果数据量比较大的搜索可能会影响到性能

相关推荐