Formpanel的setValues()方法对RadioGroup和checkGroup组建无效,需要重写BasicForm,方法如下:
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;
}
});
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;
}
});