By Alvin Alexander. Last updated: June 6, 2016
A Sencha ExtJS checkbox listener and textfield example. First, the checkbox and textfield definitions:
{ fieldLabel: 'myCheckBox' xtype: 'checkbox', name: 'myCheckBox' }, { fieldLabel: 'myTextField' xtype: 'textfield', name: 'myTextField', disabled: true }
Next, how to add a listener to the checkbox, and enable or disable the textfield when the checkbox is clicked:
listeners: { change: function() { Ext.getCmp('myTextField').disable(); //or Ext.getCmp('myTextField').enable(); } }
That shows how to use the Ext.getCmp() method. You may want to use the up
or down
methods to choose your textfield, but this code at least shows an initial approach.