Extjs2.2 usage of the declared object of RadioGroup and the getValue and SetValue Methods

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.