如何在 extjs4 中获取选项卡面板的活动选项卡的子组件?
我有一个简单的选项卡面板。我想获取当前活动选项卡的子组件并销毁它们和 doLayout()
。以下代码将不起作用:
Ext.getCmp('centertabpanel').getActiveTab().items.destroy();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里要记住的一件事是,ExtJS 中 TabPanel 中的选项卡只需是 BoxComponent 或 组件。这意味着选项卡不需要保存子元素。但是,如果您知道您的
centertabpanel
具有带有 Containers,那么您有两个选择:如果您的选项卡是一个将
autoDestroy
设置为 true(这是默认值)的容器,则只需使用:如果您想要设置
autoDestroy
设置为 false,然后使用以下代码:.each()
定义于 混合集合。它将按顺序对所有子项执行第一个参数中的函数。附带说明一下,如果您在函数内返回 false,那么它将停止元素的所有迭代。One thing to keep in mind here is that tabs in TabPanel's in ExtJS just need to be a BoxComponent in ExtJS 3 or a Component in ExtJS 4. This means that tabs are not required to hold children elements. However, if you know that your
centertabpanel
has tabs with Containers, then you have two options:If your tab is a container that has
autoDestroy
set to true (that is the default), then just use:If you want to set
autoDestroy
to false, then use the following code:.each()
is defined on MixedCollection. It will execute the function in the first parameter against all of the child items, in order. As a side note, if you return false inside the function, then it will stop all iteration of elements.