1

我创建了一个 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'
                }]  
      }  
    }]
});

我尝试了激活(),但它只能切换父选项卡。

4

1 回答 1

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);
于 2012-09-26T08:04:03.323 回答