PDA

View Full Version : Getting radio field value from a form



jop_008
2 Aug 2012, 6:11 AM
I tried several things and found this approach:


var products = Ext.ComponentQuery.query('radiofield[name=product]');
Ext.Msg.alert('getGroupValue()', products[0].getGroupValue());
} // handler
My radio button is country so I have

country = Ext.ComponentQuery.query('radiofield[name=product]');//country.length => 10
country 0].getGroupValue(); // returns no valueThe country field has a default country selected by the checkbox.
John

estesbubba
2 Aug 2012, 6:52 AM
I don't like doing these global queries as there is the potential to return multiple items. I prefer to use itemId on a form and in my controller do something like this:

view.down('#formItemId').getValues();

From there you'll have a map of field names and values.

jerome76
2 Aug 2012, 8:52 AM
I don't like doing these global queries as there is the potential to return multiple items. I prefer to use itemId on a form and in my controller do something like this:

...

He may not have a reference to the (view) in his case. I think it's a matter of opinion, though.

jop_008
2 Aug 2012, 9:18 AM
Thanks, I tried it with getValues but with no success.

John

jop_008
4 Aug 2012, 2:17 AM
Hi,

Thanks for your help so far. Regarding the radio buttons I can reach the form and can use getValues () to see what the user has filled in at the form but not for the radio fields.
For radio fields I got no value for all the other fields I got the value.

oform =
ovalues = oform.getValues ();
ovalues["radiofieldname"] no value
ovalues.radiofieldname also empty

If I do it with
ocountry = Ext.ComponentQuery.query ("radiofield[name=country]")[0]
when I walk thru the properties of ocountry (which is an object) I see _value and getGroupValue
but all resulted in an empty value

John

jop_008
7 Aug 2012, 7:01 AM
This was caused by the missing value option at the field definition.
Issue solved.

John