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

      0  

    Default Unanswered: Adding tabs from menu tree items

    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
    537
    Answers
    61
    Vote Rating
    71
    Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough

      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

Thread Participants: 1

Tags for this Thread