【发布时间】:2013-10-15 09:43:02
【问题描述】:
当我在 tabpanel 中使用 remove 方法时:
this.tabPanel.remove(tab);
它在最后设置了 setActive 选项卡。我想设置在以前的。现在我可以这样做了吗?
【问题讨论】:
当我在 tabpanel 中使用 remove 方法时:
this.tabPanel.remove(tab);
它在最后设置了 setActive 选项卡。我想设置在以前的。现在我可以这样做了吗?
【问题讨论】:
您可以处理beforeremove事件来获取被移除标签的索引并设置上一个。
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);
});
您可以查看working example。
【讨论】: