带复选框且支持搜索功能的下拉列表11


doQuery : function(q, forceAll)
{
if (q === undefined || q === null)
{ 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;
//forceAll为true指的是单击下拉框
if (forceAll){
//清除过滤条件
this.store.clearFilter();
for(var i = 0; i < this.store.getCount(); i++){
//store里头存在等于全选的一项,把flag置为false,且跳出循环
if("全选" == this.store.getAt(i).get('name')){
rec = this.store.getAt(i);
this.store.remove(this.store.getAt(i));
}
}
//如果recor不为空,并且store里存在元素,并且isExitsAll为真
//就往store里插入一项为全选的record的记录
if(rec !== undefined && rec !== null
&& this.store.getCount() > 0){
this.store.insert(0,rec);
}
}
//为false指的是键盘输入
else{
//combobox中输入的值是否和store中的相匹配
var rec_flag = false;
if(this.store.getCount()==0){
rec_flag = true;
}
//循环判断store中是否存在等于全选的记录,如果存在就把这一项移除掉
//并且把rec_flag置为true
for(var i = 0; i < this.store.getCount(); i++){
if("全选" == this.store.getAt(i).get('name')){
rec = this.store.getAt(i);
//移除存在等于全选的记录
this.store.remove(this.store.getAt(i));
rec_flag = true;
}
}
//根据在combobox中输入的值在store进行筛选
this.store.filter(this.displayField, q);
if(rec !== undefined && rec !== null && rec_flag){
//store中的记录大于0就往store里头插入全选这一项纪录
if(this.store.getCount()>0){
this.store.insert(0,rec);
}
}
}
this.onLoad();
}
else{
this.store.baseParams[this.queryParam] = q;
this.store.load({
params: this.getParams(q)
});
this.expand();
}
}
else{
this.selectedIndex = -1;
this.onLoad();
}
}
},
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值