前段时间公司项目要求一个复选框,网上找了几个都不是很符合要求,总是这里那里有点问题,所以还是自己花了点时间封装了一个。
用法和一般的EXT Combobox一样,只是多了几个配置。
check 为true时表示为复选模式,false是为单选模式
displayValue 为true时表示显示在页面上的值为Value,false时为text
displayAll 是否显示全显项
selectAllTxt 全选项的显示文本
getCheckValue() 复选模式下获得所选的value
getCheckDisplay() 复选模式下获得所选的text
由于发贴限制所以分开了几个发,最后一个带源码文件,
用法和一般的EXT Combobox一样,只是多了几个配置。
check 为true时表示为复选模式,false是为单选模式
displayValue 为true时表示显示在页面上的值为Value,false时为text
displayAll 是否显示全显项
selectAllTxt 全选项的显示文本
getCheckValue() 复选模式下获得所选的value
getCheckDisplay() 复选模式下获得所选的text
由于发贴限制所以分开了几个发,最后一个带源码文件,
Ext.util.Format.comboRenderer = function(obj){
return function(value){
var combo = this.editor;
var rst=value.split(combo.separator);
var snapshot = combo.store.snapshot || combo.store.data;
var temp = [];
if(combo.check){
for(var i=0;i<rst.length;i++){
var flag = true;
snapshot.each(function(r) {
if(r.get(combo.valueField) == rst[i]){
flag = false;
temp.push(r.get(combo.displayField));
return false;
}
}, this);
if(flag)
temp.push(rst[i]);
}
return temp.join(combo.separator);
} else{
return this.value;
}
}
};