ExtJs4 如何递归地禁用面板上的所有字段和所有按钮 [英] ExtJs4 how to disable all fields and all buttons on a panel recursively
问题描述
我正在尝试禁用面板上所有可点击、可编辑的组件.
I'm trying to disable all clickable, editable components on my panel.
调用 panel.disable()
使其变灰,但按钮仍可点击.同样的结果为 panel.cascade
提供了一个禁用每个组件的函数.
Calling panel.disable()
grays it out, but buttons are still clickable.
The same result gives panel.cascade
with a function that disables each component.
这样做的正确方法是什么?
What is the right way to do this?
推荐答案
如果您使用的是 ExtJs 4.x,这就是您正在寻找的 -
If you are using ExtJs 4.x, this is what you are looking for -
myFormPanel.query('.field, .button').forEach(function(c){c.setDisabled(false);});
(根据表单的复杂程度修改选择器.您可以只使用 .component 并禁用表单中的所有组件)
(Modify your selector based on the complexity of your form. You can just use .component and it will disable all component in your form)
另见 - Ext.ComponentQuery
如果你使用的是3.x,你可以像这样分两步达到同样的效果-
If you are using 3.x, you can achieve the same effect in two steps like this -
myFormPanel.buttons.forEach(function(btn){btn.setDisabled(true);}); //disable all buttons
myFormPanel.getForm().items.each(function(itm){itm.setDisabled(true)}); //disable all fields
这篇关于ExtJs4 如何递归地禁用面板上的所有字段和所有按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!