Pages

Thursday, June 7, 2012

Enable/Disable button in ExtJS 3.2.1

Problem Statement: How to enable disable buttons in ExtJS 3.2.1?

Problem Solution:  ExtJs button is basically instance of Ext.Button class. There are two ways we can enable/disable
  1. Using config option
  2. Programmatically enabling & disabling
USING CONFIG OPTIONS
In order to set any button enabled or disabled, config option disabled can be set as true or false.


Ext.Button({
    text: 'Edit',
    id: 'edit',
    cls: 'edit_class',
    diasabled: 'true', // button is disabled
    listeners: {
    'click': function () {}                
    }
})

Ext.Button({
    text: 'Edit',
    id: 'edit',
    cls: 'edit_class',
    diasabled: 'false', // button is enabled
    listeners: {
    'click': function () {}                
    }
})

PROGRAMMATICALLY
Ext.getCmp('edit').setDisabled(true);

Ext.getCmp('edit').setDisabled(false);

Read more : Ext JS 3.2.1 API DOCS (http://extjs.cachefly.net/ext-3.2.1/docs/)

No comments:

Post a Comment