Remove panels runtime?
January 6th, 2009
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'
}]
});
});
=D> Thanks for the quick answers...
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
}
});
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.
#If you have any other info about this subject , Please add it free.# |
Posted in freedeadaim.com | edit
A little something about you, the author. Nothing lengthy, just an overview.