PDA

View Full Version : Need help with TabPanel



nicosk
5 Nov 2009, 7:01 AM
Hi all.
I am new to Extjs and i need some help. i have an application that has 'west' (main menu), 'north'(header) and center(a tabPanel). On West i have a tree that has several companies. When one company is clicked a function is called. That function is supposed to add a tab to center and a another tabPanel(inside the newly created tab). I've searched a lot in forums but i didn't find what i wanted. Can anyone help me?
Center Panel


var centerPanel = new Ext.TabPanel({
region : 'center',
id : 'center-panel',
autoScroll : false,
activeItem : 0,
items:[{
title : "General Information",
id : 'generalInfo'
}]
});


Viewport


Ext.onReady(function(){
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
new Ext.Viewport({
layout : 'border',
items : [northPanel, westPanel, centerPanel],
renderTo : Ext.getBody()
});
});

My Function



function getCompanyInfo(node)
{
var mainTabPanel = Ext.getCmp('center-panel');
var tabExists = Ext.getCmp(node.text);

if (!tabExists) {
mainTabPanel.add({
title: node.text,
id: node.text,
closable: true,
});
mainTabPanel.setActiveTab(node.text);
}else{
mainTabPanel.setActiveTab(tabExists);
}
}

How do i add a TabPanel with predefined Tabs ?

tubamanu
5 Nov 2009, 7:18 AM
you were adding your new if it is not existing in your panel here


mainTabPanel.add({
title: node.text,
id: node.text,
closable: true,
});


u can add panel, that contains another (tab)panel and so on...



mainTabPanel.add({
xtype:'panel'
title: node.text,
id: node.text,
closable: true,
items:[{
xtype:'panel'
title:'test'
}]
});