PDA

View Full Version : Retrieve the value of Selected Radio Group Button



dev_java
9 Aug 2010, 3:41 AM
Hi All,

I faced a problem while retrieving value of the selected Radio button in the radio group.

On selecting the 'Apply' button in form panel, I have to retrieve the value of selected radio button.



{

bodyStyle: 'padding-left:5px;',
width: 300,
items: {
xtype:'fieldset',
title: 'Sorting Order',
height:125,
defaultType: 'radiogroup',
items: [
{
hideLabel:true,
items: [
{boxLabel: 'Ascending', name: 'sort-criteria', inputValue: 1},
{boxLabel: 'Descending', name: 'rsort-criteria', inputValue: 2, checked: true}

]
}
}]
}



Can anyone help me on this?

Thanks

Condor
9 Aug 2010, 3:48 AM
You need some way to locate either the radiogroup or a single radio. Could you give it an id or an itemId?

dev_java
9 Aug 2010, 4:02 AM
I tried giving id to radio group. but dint work


{

bodyStyle: 'padding-left:5px;',
width: 300,
items: {
xtype:'fieldset',
title: 'Sorting Order',
height:125,
defaultType: 'radiogroup',
items: [
{
hideLabel:true,
id:'sort_val',
items: [
{boxLabel: 'Ascending', name: 'sort-criteria', inputValue: 1},
{boxLabel: 'Descending', name: 'sort-criteria', inputValue: 2, checked: true}

]
}
}]
}

but i am not able to access the radio group itself

Condor
9 Aug 2010, 4:11 AM
Did you try:

var value = Ext.getCmp('sort_val').items.first().getGroupValue();

dev_java
9 Aug 2010, 4:27 AM
I did'nt try it this way.. i gave like
var value = Ext.getCmp('sort_val')..getGroupValue();

The code u suggested worked fine.

Thanks Condor for your help.

pratik016
27 Oct 2010, 2:08 AM
Thanks Condor.
Its rock................ :)