我有多个带字段的容器。基本上,当容器被隐藏时,所有字段都不可见。但我检查了“隐藏”属性或“isHidden()”字段的方法。我变得虚假。 我希望在隐藏容器时将其设为true,在可见时隐藏false。 如何使用覆盖
隐藏和显示字段答案 0 :(得分:0)
您的问题很难阅读。 (英语不好)但是如果我理解正确你隐藏了一个带有字段的容器。如果您然后检查其中一个字段的isHidden()
,则返回false。这是标准的Ext行为。容器隐藏的不是字段。您可以做的是查询并设置隐藏的字段。
E.g。
Ext.define('MyCustomContainer', {
extend: 'Ext.Container',
hide: function () {
var me = this;
Ext.each(me.query('field'), function (field) {
field.hide();
});
me.callParent(arguments);
},
show: function () {
var me = this;
Ext.each(me.query('field'), function (field) {
field.show();
});
me.callParent(arguments);
}
});
你问: 我不想创建自定义组件。我可以通过使用覆盖来做同样的事情吗?
是的,你可以!
我希望您没有Ext.Container
类型,它会为所有容器覆盖它,但它会起作用... =>最好用容器的特定类型替换Ext.Container
...
Ext.define('YourApp.override.Container', {
override: 'Ext.Container',
hide: function () {
var me = this;
Ext.each(me.query('field'), function (field) {
field.hide();
});
me.callParent(arguments);
},
show: function () {
var me = this;
Ext.each(me.query('field'), function (field) {
field.show();
});
me.callParent(arguments);
}
});