Joe
Joe

Reputation: 6416

How to show/hide ExtJS.Toolbar button programmatically

I am attempting to show/hide an ExtJS Toolbar button programmatically. I have tried to access the button directly, by ID using:

var btn = Ext.get('buttonID'); // I've also tried Ext.query('buttonID')
btn.show();

However, this does not cause the button to be shown. The toolbar button is defined with the ID with which I am attempting to execute the show() method.

Is there a different way for me to access the button, directly? Or, is there a different way to show it (adding/removing CSS attributes, etc.)?

Thank you in advance.

Upvotes: 3

Views: 20542

Answers (2)

TerryChen
TerryChen

Reputation: 71

The 'visible' property only works in 4.1.1+

http://jsfiddle.net/mf2jH/24/

Upvotes: 1

Chau
Chau

Reputation: 5570

If you want to show a button, which is not visible, then do

// Button definition
var btn = new Ext.Button({
    text: 'Press me!',
    visible: false,
    id: 'myButton'
});

// Now show the button.
var theSameButton = Ext.getCmp('myButton');
btn.setVisible(true);

Is this what you want?

Upvotes: 8

Related Questions