How do I programmatically hide Tab in the TabPanel (ExtJS 3)

Duleep picture Duleep · May 11, 2013 · Viewed 8.8k times · Source

This my TabPanel code:

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'
        }]
    }
});

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?

Answer

Darin Kolev picture Darin Kolev · May 11, 2013

You have two possibilities:

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

or

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