1

When I use remove method in tabpanel:

this.tabPanel.remove(tab); 

It set setActive tab in last. I would like to set on previous. Now can I do this?

4

1 回答 1

0

您可以在删除前处理事件获取已删除选项卡的索引并设置上一个。

var tabs = Ext.create('Ext.tab.Panel', {
    items: [{
        title: 'Tab 1',
        html: 'A simple tab',
        closable: true
    }, {
        title: 'Tab 2',
        closable: true,
        html: 'Another one'
    }, {
        title: 'Tab 3',
        closable: true,
        html: 'Another one'
    }],
    renderTo: Ext.getBody()
});

tabs.on('beforeremove', function(tabs, tab) {
        var idx = tabs.items.indexOf(tab) - 1;
        setTimeout(function() {
            tabs.setActiveTab(idx);
        }, 350);

});

您可以检查工作示例

于 2013-10-08T14:26:22.567 回答