CunruiLi
CunruiLi

Reputation: 493

ExtJS Nested tabpanel

I created an ExtJS nested tab panel, but I can't find out how to switch the nested tabs. Could anyone help me. Thanks a lot.

Below is my js code:

var clubs = new Ext.TabPanel({
    renderTo:'clubs',
    activeTab:0,
    autoHeight:true,
    defaults:{
      autoHeight:true,  
      cls:'tab-panel-item'  
    },
    items:[{
      title:'Shanghai',
      cls:'nested-tab',
      id:'shanghai-tab',
      items:{
        xtype:'tabpanel',
        defaults:{ cls:'tab-panel-item', autoHeight:true },
        containerCls:'nested-tab',
        activeTab:0, // required  
        items:[{
                    contentEl:'badminton',
                    title:'Badminton'
                },{
                    contentEl:'basketball',
                    title:'Basketball'
                }]  
      }  
    },{
      title:'Hangzhou',  
      cls:'nested-tab',  
      items:{  
        xtype:'tabpanel',  
        defaults:{ cls:'tab-panel-item', autoHeight:true },  
        containerCls:'nested-tab',  
        activeTab:0, // required  
        items:[{
                    contentEl:'hz-parent-child',
                    title:'Parent-child'
                },{
                    contentEl:'hz-football',
                    title:'Football'
                }]  
      }  
    }]
});

I tried the activate(), but it only can switch the parent tabs.

Upvotes: 1

Views: 1799

Answers (1)

sra
sra

Reputation: 23975

I guess you are using ExtJS 3.x ? And from where do you wan't to change the tab?

You could use Ext.getCmp('Your-Tab-Panel-Id');

var clubs = new Ext.TabPanel({
    renderTo:'clubs',
    activeTab:0,
    autoHeight:true,
    defaults:{
      autoHeight:true,  
      cls:'tab-panel-item'  
    },
    items:[{
      title:'Shanghai',
      cls:'nested-tab',
      id:'shanghai-tab',
      items:{
        xtype:'tabpanel',
        id:'shanghai-tab-nested-first',
        defaults:{ cls:'tab-panel-item', autoHeight:true },
        containerCls:'nested-tab',
        activeTab:0, // required  
        items:[{
                    contentEl:'badminton',
                    title:'Badminton'
                },{
                    contentEl:'basketball',
                    title:'Basketball'
                }]  
      }  
    },{
      title:'Hangzhou',  
      cls:'nested-tab',  
      items:{  
        xtype:'tabpanel',  
        id:'shanghai-tab-nested-second',
        defaults:{ cls:'tab-panel-item', autoHeight:true },  
        containerCls:'nested-tab',  
        activeTab:0, // required  
        items:[{
                    contentEl:'hz-parent-child',
                    title:'Parent-child'
                },{
                    contentEl:'hz-football',
                    title:'Football'
                }]  
      }  
    }]
});

Ext.getCmp('shanghai-tab-nested-second').Activate(1);
Ext.getCmp('shanghai-tab-nested-first').Activate(1);

Upvotes: 1

Related Questions