PDA

View Full Version : How to reset a radio button value on click of reset button



varmaj80
3 Aug 2014, 2:38 PM
Hello,

I am having a radio group with two radio buttons as follows.

{
xtype: 'container',
defaultType: 'radiofield',
layout: 'hbox',
items: [
{
boxLabel: 'Asc',
name: 'sortDirect',
checked: true,
inputValue:'asc',
left:'60px',
cls:'ascRadio'
}, {
boxLabel: 'Desc',
name: 'sortDirect',
inputValue:'desc',
cls:'dscRadio'
}]
}

By default, the 'asc' button is selected on page load. If I select the Desc button, it gets selected. Now when I click on the reset button on the page. the 'asc' button should get selected. I am not able to use the form.getForm() or form.getFields() as I am defining this .js file by using
extend: 'Ext.window.Window', So not sure if the form works here.

I am able to reset the rest of the text fields or combo boxes using this.child() and this.setValue. But now sure how I can use this for a radio button fields.
Any suggestions please?....

Thanks....

Farish
4 Aug 2014, 11:20 PM
one way of doing it is to use a radiogroup instead of container xtype. radiogroup has a reset method which resets the button to the initial config. you can use


form.down('radiogroup').reset();

to mark the initially checked radiobutton again.