如何在 extjs4 中获取选项卡面板的活动选项卡的子组件?

发布于 2024-12-14 09:01:38 字数 163 浏览 2 评论 0 原文

我有一个简单的选项卡面板。我想获取当前活动选项卡的子组件并销毁它们和 doLayout()。以下代码将不起作用:

Ext.getCmp('centertabpanel').getActiveTab().items.destroy();

I have a simple tabpanel. I want to fetch currently active tab's child components and destroy them and doLayout(). The following code won't work:

Ext.getCmp('centertabpanel').getActiveTab().items.destroy();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满天都是小星星 2024-12-21 09:01:38

这里要记住的一件事是,ExtJS 中 TabPanel 中的选项卡只需是 BoxComponent组件。这意味着选项卡不需要保存子元素。但是,如果您知道您的 centertabpanel 具有带有 Containers,那么您有两个选择:

如果您的选项卡是一个将 autoDestroy 设置为 true(这是默认值)的容器,则只需使用:

    Ext.getCmp('centertabpanel').getActiveTab().removeAll();

如果您想要设置autoDestroy 设置为 false,然后使用以下代码:

    Ext.getCmp('centertabpanel').getActiveTab().each(function(item, idx, len) {
        item.destroy();
    });

.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:

    Ext.getCmp('centertabpanel').getActiveTab().removeAll();

If you want to set autoDestroy to false, then use the following code:

    Ext.getCmp('centertabpanel').getActiveTab().each(function(item, idx, len) {
        item.destroy();
    });

.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文