1. 程式人生 > >Ext JS 實現建議詞模糊動態搜索功能

Ext JS 實現建議詞模糊動態搜索功能

uefi store node cor emp phone jsonstore ons .json

代碼:

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‘ 為當選擇某個數據的時候需要執行的回調;

這種方法適用數據量小的搜索,如果數據量比較大的搜索可能會影響到性能

Ext JS 實現建議詞模糊動態搜索功能