简体   繁体   English

如何以编程方式显示/隐藏ExtJS.Toolbar按钮

[英]How to show/hide ExtJS.Toolbar button programmatically

I am attempting to show/hide an ExtJS Toolbar button programmatically. 我试图以编程方式显示/隐藏ExtJS工具栏按钮。 I have tried to access the button directly, by ID using: 我试图通过ID直接访问该按钮:

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. 工具栏按钮定义了我尝试执行show()方法的ID。

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.)? 或者,是否有不同的方式来显示它(添加/删除CSS属性等)?

Thank you in advance. 先感谢您。

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? 这是你想要的吗?

The 'visible' property only works in 4.1.1+ “可见”属性仅适用于4.1.1+

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM