Ext js 下拉框下拉的同时输入模糊查询
var joincmpcombo = new Ext.form.ComboBox({//设计师
id: 'joincmp_name',
name: 'joincmp_name',
hiddenName: 'joincmp', //后台获取的是id的值
fieldLabel: '联盟商',
valueField: 'joincmp_id', //ComboBox的值,如果提交表单,这个值是要传到后台的
displayField: 'joincmp_name', //这个是下拉框显示的值
allowBlank: true, //是否允许为空
blankText: '请选择联盟商', //为空显示的值
triggerAction: 'all', //显示所有下拉框的值
typeAhead:true,
store: joincmp,
anchor: '95%',
mode: 'local' ,//必须用本地加载
editable:true,
queryParam:'text',
listeners : {
'beforequery':function(e){
var combo = e.combo;
if(!e.forceAll){
var value = e.query;
var regExp = new RegExp(".*" + value + ".*");
combo.store.filterBy(function(record,id){
var text = record.get(combo.displayField);
return regExp.test(text);
});//alert(0);
combo.expand();
return false;
}
}
}
});
id: 'joincmp_name',
name: 'joincmp_name',
hiddenName: 'joincmp', //后台获取的是id的值
fieldLabel: '联盟商',
valueField: 'joincmp_id', //ComboBox的值,如果提交表单,这个值是要传到后台的
displayField: 'joincmp_name', //这个是下拉框显示的值
allowBlank: true, //是否允许为空
blankText: '请选择联盟商', //为空显示的值
triggerAction: 'all', //显示所有下拉框的值
typeAhead:true,
store: joincmp,
anchor: '95%',
mode: 'local' ,//必须用本地加载
editable:true,
queryParam:'text',
listeners : {
'beforequery':function(e){
var combo = e.combo;
if(!e.forceAll){
var value = e.query;
var regExp = new RegExp(".*" + value + ".*");
combo.store.filterBy(function(record,id){
var text = record.get(combo.displayField);
return regExp.test(text);
});//alert(0);
combo.expand();
return false;
}
}
}
});