radio-buttonlistenersencha-touch

add listener to radio field in sencha


I am creating radiofields in my web app programatically which are initially checked. I am trying to add a listener to the radio field, which listens to ''uncheck' event. On getting unchecked I want to destroy the radio field.

The radio field is added and created just fin but on unchecking the field I get the following error.

Uncaught TypeError: Cannot call method 'replace' of null

The code for initialising radio field.

var radioField= Ext.create('Ext.field.Radio',{
            id:fieldName,
                checked:true,
        label:fieldName,
         listeners: {
          uncheck: function() {
          console.log('destroy');
          destroy();
        }
      }
});
Ext.getCmp('filterListField').add(radioField);

Solution

  • I believe name is a required property for radiobox. I did this and it seems to work.

    var radioField = Ext.create('Ext.field.Radop', {
                        id: fieldName,
                        checked: true,
                        name:fieldName,
                        label: fieldName,
                        listeners: {
                            'uncheck': function(radio) {
                                console.log('destroy');
                                radio.destroy();
                            }
                        }
                    });
     Ext.getCmp('QC23View').add(radioField);