-
7 Mar 2012 7:51 AM #1
Unanswered: Get value of radio group
Unanswered: Get value of radio group
I have got below panel as an item in another panel.
My issue is how to get the 'checked' radio button from this radio group(face). Any help will be highly appreciated. Cheers
Code:var faceRating = new Ext.Panel({ height:50, width:160, //bodyPadding:'0 0 0 20', //bodyMargin:'0 0 0 10', layout:{ type:'hbox', pack:'justify', }, items:[ { xtype:'radiofield', name:'face', width:40, cls:'radio_rating', height:40, margin:'0 7 0 7', }, { xtype:'radiofield', name:'face', width:40, cls:'radio_rating', height:40, margin:'0 7 0 7', }, { xtype:'radiofield', name:'face', width:40, cls:'radio_rating', height:40, margin:'0 7 0 7', }, { xtype:'radiofield', name:'face', width:40, cls:'radio_rating', height:40, margin:'0 7 0 7', }, ], });
-
7 Mar 2012 8:27 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,639
- Vote Rating
- 435
- Answers
- 3106
Try this:
Code:var faceRating = new Ext.form.FormPanel({ fullscreen : true, height:50, width:160, layout:{ type:'hbox', pack:'justify' }, items:[ { xtype:'radiofield', name:'face', width:40, cls:'radio_rating', height:40, margin:'0 7 0 7', value : 'one' }, { xtype:'radiofield', name:'face', width:40, cls:'radio_rating', height:40, margin:'0 7 0 7', value : 'two' }, { xtype:'radiofield', name:'face', width:40, cls:'radio_rating', height:40, margin:'0 7 0 7', value : 'three' }, { xtype:'radiofield', name:'face', width:40, cls:'radio_rating', height:40, margin:'0 7 0 7', value : 'four' } ], dockedItems : [ { xtype : 'toolbar', dock : 'top', items : [ { text : 'Get Value', handler : function() { var field = faceRating.query('radiofield'); console.log(field[0].getGroupValue()); } } ] } ] });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Mar 2012 9:18 AM #3
Can I do this without extending FormPanel but Panel?
-
7 Mar 2012 9:28 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,639
- Vote Rating
- 435
- Answers
- 3106
The getGroupValue requires the form.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Mar 2012 9:39 AM #5
By getting clue from your sample code , I used following code still using Panel . I know it may NOT best in performance factor but did work .
Code:handler: function(){ var faceRatingValueArray= faceRating.query('radiofield'); var faceRatingValue=""; for(var i=0;i<faceRatingValueArray.length;i++){ if(faceRatingValueArray[i].isChecked()) faceRatingValue=legsRatingValueArray[i].getValue(); }
-
4 Nov 2012 10:58 PM #6
Use getSubmitValue()
Use getSubmitValue()
I ran into the same problem and then checked the source code for Radio class and it turns out that getValue() method returns either 'true' or 'null'.
Since getGroupValue() calls getValue() in it's return statement it will only return 'true' or 'null'.
This is obviously a bug.
The workaround is to use getSubmitValue() instead.


Reply With Quote