I have a Radio group having radio buttons Male and Female. Please see below code
{
xtype: 'radiogroup',
fieldLabel: 'Gender',
name: 'rbGender',
defaults: {
flex: 1
},
layout: 'hbox',
items: [
{
boxLabel: 'Male',
name: 'gender',
inputValue: false,
//checked: true,
id: 'radio1'
},
{
boxLabel: 'Female',
name: 'gender',
inputValue: true,
id: 'radio2'
}
]
}
I am unable to set these radio fields when I am getting values from database of gender field Male or Female(true/false).
please see below code.
if (rec[0].gender == true) {
me.form.getForm().findField('gender').setValue(true);
}
else if (rec[0].gender == false) {
me.form.getForm().findField('gender').setValue(true);
};
how to set male female radio button by database gender field value
You just pass an object, with the radio item name as the key and the value, like:
setValue({gender: true}) // will set the female as selected.
Working example: https://fiddle.sencha.com/#view/editor&fiddle/1o8c