ExtJS嵌套tabpanel

时间:2012-09-26 06:32:21

标签: extjs

我创建了一个ExtJS嵌套选项卡面板,但我找不到如何切换嵌套选项卡。任何人都可以帮助我。非常感谢。

以下是我的js代码:

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

我尝试了activate(),但它只能切换父标签。

1 个答案:

答案 0 :(得分:1)

我猜你在使用ExtJS 3.x? 从哪里可以更改标签?

您可以使用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);