Friends who have used it all know that the setValue and SetValue of the RadioGroup component of extjs seem to have bugs. It is unsuccessful.
Here I will solve this problem:
1. Code for declaring RadioGroup:
[Javascript]
Var radiogroup = new Ext. form. RadioGroup ({
FieldLabel: "gender ",
Items :[{
BoxLabel: 'male ',
InputValue: '1 ',
Checked: true,
Name: "radSex"
},{
BoxLabel: 'Female,
Name: "radSex ",
InputValue: '2'
}]
});
2. Override the SetValue and GetValue methods to obtain available methods.
[Javascript]
Ext. override (Ext. form. RadioGroup ,{
GetValue: function (){
Var v;
If (this. rendered ){
This. items. each (function (item ){
If (! Item. getValue ())
Return true;
V = item. getRawValue ();
Return false;
});
}
Else {
For (var k in this. items ){
If (this. items [k]. checked ){
V = this. items [k]. inputValue;
Break;
}
}
}
Return v;
},
SetValue: function (v ){
If (this. rendered)
This. items. each (function (item ){
Item. setValue (item. getRawValue () = v );
});
Else {
For (var k in this. items ){
This. items [k]. checked = this. items [k]. inputValue = v;
}
}
}
});
3. Call the method to complete the settings:
[Javascript]
Radiogroup. getValue () // obtain the value of inputValue.
Radiogroup. setValue ("1"); // you can select the value.