View Full Version : Adding tabs from menu tree items

20 Sep 2012, 4:58 AM
Hello everyone.
I have a problem with adding tabs to a tab panel when i click a menu item. Here is my code

var mainMenuTree = Ext.create('Ext.tree.Panel', {
store: mainMenuTreeStore,
rootVisible: false,
border : false,
bodyPadding : 5,
listeners : {
itemclick : function(view, record, item, index, evt, eOpts) {
var text = record.get('text');
var id = record.internalId;
var leaf = record.data.leaf;
if(leaf === true) {
var newTab = MainUITabPanel.add({
title : text,
id : id,
layout : 'fit',
items : [eval(id)],
closable : true,
border : false,
frame : false

My problem is that when i click again on the same menu item it adds the same tab to the tab panel. and if i click again it adds it for a third time. is there a config or property i have to enable either to the tab or tab panel!
thank you

Tim Toady
20 Sep 2012, 5:32 AM
Well you have an id on the tab when you add it. Instead of just checking for leaf you could also check if the tab already exists on the tabpanel using getComponent.