Ext JS 4 Radio Check Event

I am creating a radioGroup in extJS 4 using xtype inside a FormPanel. I am trying to enable / disable the text box as soon as the radio is checked.

{
xtype: 'radiogroup',
fieldLabel: 'Enable / Disable ',
columns: 2,
vertical: true,
items: [
     {boxLabel: 'Enable', name: 'formtype', inputValue: '1'},
     {boxLabel: 'Disable', name: 'formtype', inputValue:'2',checked:true},
    ]
 }

I am confused where to add listeners for check / click. Thanks for the ton in advance.

+3
source share
2 answers

You must handle the change event on each switch. When the radio button changes (selected), enable / disable the text box.

Following the example:

Ext.create ('Ext.container.Container', {
    renderTo: Ext.getBody () ,
    items: [{
        xtype: 'textfield' ,
        id: 'tf' ,
        disabled: true ,
        fieldLabel: 'My Text'
    } , {
        xtype: 'radiogroup',
        fieldLabel: 'Enable / Disable ',
        columns: 2,
        vertical: true,
        items: [{
            boxLabel: 'Enable',
            name: 'formtype' , 
            inputValue: '1' ,
            listeners: {
                change: function (cb, nv, ov) {
                    if (nv) Ext.getCmp('tf').enable ();
                }
            }
        } , {
            boxLabel: 'Disable', 
            name: 'formtype', 
            inputValue:'2',
            checked: true ,
            listeners: {
                change: function (cb, nv, ov) {
                    if (nv) Ext.getCmp('tf').disable ();
                }
            }
        }]
    }]
});

Ciao

+11
source

( ), . / newVal oldVal. newVal , .

+2

All Articles