Ext Compbox
3174 ワード
onLoad : function() {
Dma.common.DmaCommon.superclass.onLoad.call(this);
// SELECT ALL
var snapshot = this.store.snapshot || this.store.data;
var f = true;
snapshot.each(function(r){
if(r.get(this.displayField) == this.selectAllTxt){
f = false;
}
},this);
if(f){
var rec = new Ext.data.Record();
rec.set(this.displayField, this.selectAllTxt);
this.store.insert(0, rec);
}
/*if (this.flag == 0 && this.check) {
if(this.displayAll){
var rec = new Ext.data.Record();
rec.set(this.displayField, this.selectAllTxt);
this.store.insert(0, rec);
}
} else if (this.check) {
var i = 0;
var snapshot = this.store.snapshot || this.store.data;
snapshot.each(function(r) {
if (r.get(this.displayField) == this.selectAllTxt) {
i = 1;
}
}, this);
if (i != 1) {
this.flag = -1;
}
}
this.flag++;*/
/*if(this.check && this.value!=null){
// , value , ,
var rst=this.value.split(this.separator);
var snapshot = this.store.snapshot || this.store.data;
snapshot.each(function(r) {
if(r.get(this.displayField) == this.selectAllTxt){
if(this.hasSelectAll)
r.set(this.checkField, true);
else
r.set(this.checkField, false);
} else{
for(var i=0;i<rst.length;i++){
if(rst[i]==r.get(this.displayField) || rst[i]==r.get(this.valueField)){
r.set(this.checkField,true);
break;
}else{
r.set(this.checkField,false);
}
}
}
},this);
}*/
},
expand: function(){
Dma.common.DmaCommon.superclass.expand.call(this);
if(this.check ){
var val = this.value == null ? '': this.value;
var rst=val.split(this.separator);
var snapshot = this.store.snapshot || this.store.data;
snapshot.each(function(r) {
if(this.hasSelectAll){
r.set(this.checkField, true);
} else{
for(var i=0;i<rst.length;i++){
if(rst[i]==r.get(this.displayField) || rst[i]==r.get(this.valueField)){
r.set(this.checkField,true);
break;
}else{
r.set(this.checkField,false);
}
}
}
},this);
}
},
checkSelectAll: function(){
var snapshot = this.store.snapshot || this.store.data;
snapshot.each(function(r) {
if(r.get(this.displayField) == this.selectAllTxt){
if(this.hasSelectAll)
r.set(this.checkField, true);
else
r.set(this.checkField, false);
return false;
}
},this);
},
isSelectAll: function() {
return this.hasSelectAll;
},
getHiddenValue: function(){
return this.hiddenValue;
}
});