View Full Version : RadioGroup setting value through the form's setValues method

14 Aug 2009, 10:58 AM

I'm trying to figure out a way to set a RadioGroup value through the form's setValues method, and so far, I haven't been successful. I'm not sure what's the best approach here.

According to the api, the RadioGroup has a method setValue( radio/id, boolean value) but how does it work with the actual form.setValues? Maybe it's cause it's the end of the week but I'm just not seeing it clearly...

As in

'myText1' : 'valueNo1',
'myText2' : 'valueNo2',
'myRadioGroup' : ???? });

I also tried to set the value for the actual Radio ('myRadioGroupFirstOption' : true), without any success.

Ext.getCmp('myRadioGroupFirstOption').setValue(true); does work however, but I would rather avoid this solution if at all possible.

Any ideas / comments welcomed!


Dr. Flink
9 Oct 2009, 5:25 AM
myRadioGroup: 'b'

var foo = new Ext.form.RadioGroup({
fieldLabel: 'My radio group',
name: 'myRadioGroup',
width: 110,
height: 15,
items: [
{boxLabel: 'This is A', name:'myRadioGroup', inputValue: 'a'},
{boxLabel: 'This is B', name:'myRadioGroup', inputValue: 'b'}, // This radio will be selected through
{boxLabel: 'This is C', inputValue: 'c'}
Rembember that inputValue MUST be a string and not a number. Any number must be surrounded with citation marks:
Will not work: {inputValue: 1234}
Will work: {inputValue: "1234"}

However, could someone tell me why the name in each radio item has to be specified? Shouldn't specifying the name for the radiogroup be enough?

21 Jun 2010, 8:30 PM
Altought this would be fine for radigroup, as only one value in group wil be selectd, this wont work for checkbox goup, as there can be multiple checkboxes selected!
Anyone have solution, as setting value for checkbox group items DOES NOT WORK!

Dr. Flink
22 Jun 2010, 3:37 AM
Well, the keys has to be unique, so you have to pass an array of values to the function instead of an object:

Will not work, only the last value will be set (the others is beeing overwritten)

{'myCheckboxGroup': 'a'},
{'myCheckboxGroup': 'b'},
{'myCheckboxGroup': 'c'}

Will work

{id:'myCheckboxGroup', value:'a'},
{id:'myCheckboxGroup', value:'b'},
{id:'myCheckboxGroup', value:'c'}