tabPanel的隐藏与激活
本帖最后由 u011504926 于 2013-08-07 15:41:46 编辑 在一个panel中优先建立了两个tabPanel页
var oneTab = addTabPage("1",APanel);
var twoTab = addTabPage("2",BPanel);
tabPanel.setActiveTab(oneTab);
这个function addTabPage如下代码
var tabPanel = Ext.create('Ext.tab.Panel', {
frame: false,
fitToFrame: true,
tabBar: {
height: 22,
defaults: {
height: 22
}
},
deferredRender: false
});
function addTabPage(title, form) {
var index = tabPanel.items.length + 1;
for (var i = 0; i < tabPanel.items.length; i++) {
var tab = tabPanel.items.getAt(i);
var t = tab.title;
if (t == title) {
tabPanel.setActiveTab(tab);
return false;
}
}
var tabPage = tabPanel.add({
xtype: 'panel',
title: title,
layout: 'fit',
fitToFrame: true,
closable: false
})
tabPage.add(form);
return tabPage;
}
var addBtn = Ext.create('Ext.button.Button', {
text: '我是隐藏AB新增C',
iconCls: 'icon_add',
handler: function () {
tabPanel.hide(APanel) ;
tabPanel.hide(BPanel) ;
// tabPanel.show( loanRepayPanel) ;
var threeTab = addTabPage('3', CPanel);
tabPanel.setActiveTab(threeTab);
tabPanel.show(CPanel); ;
}
});
{
text:'删除标签',
handler:function(){
var t = tabPanel.getActiveTab();//获得当前活动的标签的引用
if(t.closeable){
tabPanel.remove(t);//删除标签
}else{
Ext.Msg.alert("提示","该标签不能关闭");
}
}
}