Remove panels runtime?

January 6th, 2009
  • Hi.
    How do I remove subPanels runtime?
    I have tried several ways, but no one works...

    Ext.onReady(function() {
    var button = new Ext.Button({
    renderTo: Ext.getBody(),
    text: 'click to remove',
    handler: function() {
    // Remove panels code here
    mainPanel.items.clear();
    mainPanel.doLayout();
    }
    })

    var mainPanel = new Ext.Panel({
    renderTo: Ext.getBody(),
    width: 100,
    height: 300,
    items: [{
    title: 'Panel 1',
    id: 'panel1'
    },{
    title: 'Panel 2',
    id: 'panel2'
    },{
    title: 'Panel 3',
    id: 'panel3'
    },{
    title: 'Panel 4',
    id: 'panel4'
    },{
    title: 'Panel 5',
    id: 'panel5'
    }]
    });
    });


  • Yes, that was what I was looking for, but it seems like you have to count though all panels and remove them one by one.

    =D> Thanks for the quick answers...


  • Hi.
    How do I remove subPanels runtime?

    It would be nice if Ext.Container provided a removeAll method:


    Ext.override(Ext.Container, {

    removeAll : function(autoDestroy){
    var item, removed=;
    while( item = this.items.last() ){
    removed.unshift ( this.remove(item,autoDestroy) );
    }
    if(!!removed.length) { this.doLayout(); }
    return removed; //an array in original layout order
    }

    });


  • ... but it seems like you have to count though all panels and remove them one by one.


    Indeed. But you must use the Container's remove methods as they are designed to cleanup child items (invoking their destroy methods) properly. If not, you'll leave hundreds of orphans and event listeners behind.


  • http://extjs.com/deploy/dev/docs/?class=Ext.Panel&member=remove







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Remove panels runtime? , Please add it free.