在Ext2.2的Ext.form.FormPanel中如果有RadioGroup或者CheckboxGroup,那么FormPanel.form.setValues方法对这2个东东内部的radio和checkbox无法动态赋值,需要对Ext.form.BasicForm的findField方法进行修正,代码如下:
Ext.override(Ext.form.BasicForm,{
findField : function(id){
var field = this.items.get(id);
if(!field){
this.items.each(function(f){
if(f.isXType('radiogroup')||f.isXType('checkboxgroup')){
f.items.each(function(c){
if(c.isFormField && (c.dataIndex == id || c.id == id || c.getName() == id)){
field = c;
return false;
}
});
}
if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
field = f;
return false;
}
});
}
return field || null;
}
});
findField : function(id){
var field = this.items.get(id);
if(!field){
this.items.each(function(f){
if(f.isXType('radiogroup')||f.isXType('checkboxgroup')){
f.items.each(function(c){
if(c.isFormField && (c.dataIndex == id || c.id == id || c.getName() == id)){
field = c;
return false;
}
});
}
if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
field = f;
return false;
}
});
}
return field || null;
}
});