如何以编程方式隐藏TabPanel中的Tab(ExtJS 3) [英] How do I programmatically hide Tab in the TabPanel (ExtJS 3)

查看:824
本文介绍了如何以编程方式隐藏TabPanel中的Tab(ExtJS 3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的TabPanel代码:

This my TabPanel code:

在代码中有两个选项卡(tab1和tab2)在TabPanel(tabs_panel)中

inside the code there is two tabs (tab1 and tab2) in the TabPanel (tabs_panel)

MyTabPanelUi = Ext.extend(Ext.TabPanel, {
    activeTab: 0,
    height: 210,
    resizeTabs: true,
    tabWidth: 266,
    id: 'tabs_panel',
    initComponent: function () {
        this.items = [{
            xtype: 'panel',
            title: 'Project',
            padding: 20,
            height: 150,
            id: 'tab1'
        }, {
            xtype: 'panel',
            title: 'Service',
            height: 150,
            padding: 20,
            id: 'tab2'
        }]
    }
});

我试图隐藏tab2使用下面的代码,但这个下面的代码

I'm trying to hide tab2 using bellow code but this bellow code

var tabPanel = Ext.getCmp('tabs_panel');
var tabToHide = Ext.getCmp('tab2');
tabPanel.hideTabStripItem(tabToHide);

但不知何故,上面的代码对我来说不起作用。如何解决问题?

but somehow this above code does not work for me. How can I fix the problem?

推荐答案

您有两种可能:

var tabPanel = Ext.getCmp('tabs_panel');
tabPanel.hideTabStripItem("tab2"); // with tab id

var tabPanel = Ext.getCmp('tabs_panel');
tabPanel.hideTabStripItem(1); // with tab index

这篇关于如何以编程方式隐藏TabPanel中的Tab(ExtJS 3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆