admin管理员组

文章数量:1394759

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?

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?

Share Improve this question edited May 11, 2014 at 16:31 Darin Kolev 3,40913 gold badges33 silver badges47 bronze badges asked May 11, 2013 at 5:56 DuleepDuleep 5876 gold badges26 silver badges50 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

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

try this one

Ext.getCmp("tab").child('#id').tab.hide()

本文标签: javascriptHow do I programmatically hide Tab in the TabPanel (ExtJS 3)Stack Overflow