Results 1 to 3 of 3

Thread: How to create / destroy tab dynamically

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    18

    Default How to create / destroy tab dynamically

    Hi,
    I have a list of tabs, what I want is whenever i switch a tab, the items are added to the tab and it is redrawn, and the old tab is destroyed.

    This is how i tried to do it, but its not working

    Code:
    view=    Ext.Viewport.add({                
                    xtype : 'tabpanel',  
                    deferredRender:false,
                    tabBarPosition : 'bottom',
                    items : tabs,
                    listeners : 
                    {
                        activeitemchange : function(container, newValue, oldValue,opts)
                        {
                            // --> destroy old tab
                            index = container.items.findIndex('id',newValue.id);
                            newValue.items = tabItems[index];
                            // --> redraw new tab
                        }
                    }
    });
    How can i do this ? (doLayout doesn't seem to work on newValue, and destroy doesn't destroy only the items)

    Thank you.

  2. #2
    Sencha User AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Answers
    148

    Default

    Hi,
    is not really clear why you want to do that but this is how you should do that.

    Code:
    activeitemchange : function(container, newTab, oldTab, opts)
    {
    
        newTab.add(oldTab.getItems());
    
        oldTab.destroy();
    
    }
    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    18

    Default

    Thank you for your response,
    What I want to do, is have the normal behavior of the tabs, just for performance reasons, i want to destroy the tabs contents when they're not visible.

    newTab.add(MyItems);
    is actually what i needed

    There is still the destroy of items of oldTab (
    oldTab.destroy();

    removes the whole tab, so i can't get back to it )
    How should i remove only the items,
    And is what I'm doing better for performance

    Thank you for any advice

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
  •