Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable button Ext JS

Tags:

extjs

I have a button with id of btnAdd and I want to disable it when some event is fired. The event occurs when some window is closed. So I tried the following code and it does not work.

Ext.create('Ext.window.Window', {
    // Some initialization code goes here...
    listeners: {
       close: function(panel, eOpts){
          Ext.get('btnAdd').disable(); // this does not work;
          Ext.get('btnAdd').setDisabled(); // this one does not either
          Ext.get('btnAdd').disabled = true; // And this one also seems to do nothing
       }
    }
});

How can I do that? This may seem to be pretty easy question but don't judge me bad. I'm quite new to Ext JS. I could not find the answer in the API Documentation either.

like image 209
Dimitri Avatar asked Jun 26 '13 07:06

Dimitri


2 Answers

Ext.get('btnAdd').setDisabled(true);

http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.button.Button-method-setDisabled

like image 154
zerkms Avatar answered Sep 28 '22 07:09

zerkms


Ext.get('btnid').disable();
Ext.get('btnid').setDisabled(true);

both return errors, the best way that work without issues is

Ext.getCmp('btnid').setDisabled(true) 

and you can set a text when the button is disabled to notify the user.

Example:

Ext.getCmp('btnid').setText("Button has been disabled")
like image 37
Asanda Lamba Avatar answered Sep 28 '22 08:09

Asanda Lamba