Results 1 to 2 of 2

Thread: Adding tabs from menu tree items

  1. #1
    Sencha User drumforhim's Avatar
    Join Date
    May 2011
    Location
    Greece
    Posts
    14
    Vote Rating
    0
      0  

    Default Unanswered: Adding tabs from menu tree items

    Hello everyone.
    I have a problem with adding tabs to a tab panel when i click a menu item. Here is my code
    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
                    });
                    MainUITabPanel.setActiveTab(newTab);        
                }        
            }
        }
    });
    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

  2. #2
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    603
    Answers
    67
    Vote Rating
    284
      0  

    Default

    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.
    http://docs.sencha.com/ext-js/4-1/#!...d-getComponent

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •