[英]Extjs proper way to show/hide
I'm a little new to Extjs and I'm trying to figure out the proper way to show/hide elements. 我对Extjs有点陌生,我试图找出显示/隐藏元素的正确方法。
I have the following elements: 我具有以下要素:
layout: 'card',
items:
[
{
xtype: 'Panel1'
},
{
xtype: 'Panel2'
}
]
In my controller I have these references setup: 在我的控制器中,我具有以下参考设置:
refs: [
{
ref: 'p1',
selector: 'Panel1'
},
{
ref: 'p2',
selector: 'Panel2'
}
],
Each panel has a form and two buttons at the bottom. 每个面板在底部都有一个窗体和两个按钮。 Panel 2 is hidden in the beginning.
面板2隐藏在开头。 Now I want to show Panel 2 and hide Panel 1. First I tried:
现在,我想显示面板2并隐藏面板1。首先,我尝试:
this.getp1().hide();
this.getp2().show();
...and that did nothing. ...那什么也没做。 Then, I found this SO question and tried out the following:
然后,我发现了这个SO问题并尝试了以下方法:
this.getp1().getEl().hide();
this.getp2().getEl().show();
which partially worked except that it failed to also show the buttons in Panel2. 除了不能同时显示Panel2中的按钮之外,它部分起作用。 Am I supposed to get every single element and
show()
each of them? 我是否应该获取每个元素并对其进行
show()
? I must be missing something. 我肯定错过了什么。
try with: 尝试:
this.getP1().hide(); //the first letter should be uppercase
this.getP2().show();
The parent panel of my two problem items was of a layout: 'card'
. 我的两个问题项的父面板是一个
layout: 'card'
。 According to the sencha docs on the Card layout only one panel will be shown at a time. 根据卡片布局上的sencha文档,一次只能显示一个面板。 Therefore, the proper way to show other items is not via the show/hide function, but rather calling
PARENT_PANEL.getLayout().setActiveItem(n);
因此,显示其他项目的正确方法不是通过show / hide函数,而是调用
PARENT_PANEL.getLayout().setActiveItem(n);
That was causing my p2 panel to always be hidden and not affected by the show()
method. 这导致我的p2面板始终处于隐藏状态,而不受
show()
方法的影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.