I have created RadioGroup using the code
var radios = new Ext.form.RadioGroup({
columns : 2,
items: [
{boxLabel: 'E-Mail', name: 'communication', inputValue: 1},
{boxLabel: 'Nagios', name: 'communication', inputValue: 2}
]
});
I want to check one of the radio button on some event. How to do it? I tried using:
radios.setValue(true, false);
but it is not working.
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.RadioGroup-method-setValue
var form = Ext.create('Ext.form.Panel', {
title : 'RadioGroup Example',
width : 300,
bodyPadding : 10,
renderTo : Ext.getBody(),
items : [
{
xtype : 'radiogroup',
fieldLabel : 'Group',
items : [
{ boxLabel : 'Item 1', name : 'rb', inputValue : 1 },
{ boxLabel : 'Item 2', name : 'rb', inputValue : 2 }
]
}
],
tbar : [
{
text : 'setValue on RadioGroup',
handler : function () {
// Set the value of the 'rb' radio butons
var val = {rb : 2};
form.child('radiogroup').setValue(val);
}
}
]
});
radios.items.items should return you the radio buttons inside the radio group. You can then use the setValue() function on them to check or uncheck them.
radios.items.items[index].setValue(true/false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With