javascript 如何以编程方式显示/隐藏 ExtJS.Toolbar 按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5379862/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to show/hide ExtJS.Toolbar button programmatically
提问by Joe
I am attempting to show/hide an ExtJS Toolbar button programmatically. I have tried to access the button directly, by ID using:
我试图以编程方式显示/隐藏 ExtJS 工具栏按钮。我尝试通过 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.
先感谢您。
回答by Chau
If you want to showa 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?
这是你想要的吗?
回答by TerryChen
The 'visible' property only works in 4.1.1+
“可见”属性仅适用于 4.1.1+