View Full Version : how to properly remove a panel

8 May 2009, 7:35 AM

I am dynamically creating and removing panels. Is there anything that I need to do (from a memory-release perspective) aside from just removing a panel from the parent container?

I have created some re-usable content panels and am trying to determine what method to override to null out class variables... I have tried
- onRemove
- onUnload
neither of these methods are executed when I remove the panel from it's container. Thank you very much for the help.

Joe Hudson

8 May 2009, 7:44 AM
If you are not creating custom classes (extending), you'll may want to use the simple 'beforedestroy' listeners to handle specific cleanup tasks.

id : 'test',
title: 'Test',
setSomeRefs : function(){
this.canvasEl = this.body.dom; //important to cleanup these DOM references up

render : function(){ this.setSomeRefs() },
beforedestroy : function(){
this.canvasEl = null;

somePanel.rendered && somePanel.doLayout(); //always call if the Container is already rendered.
Then later:

somePanel.remove('test',true); //forceful destruction

8 May 2009, 8:59 AM
Thank you for the reply.

What would be the appropriate GXT way of doing this? I see a remove method on LayoutContainer but it doesn't take an additional boolean parameter to optionally destroy the panel. And, I don't see a destroy method on LayoutContainer... Thanks.

Joe Hudson

8 May 2009, 9:03 AM
Ah, GXT User ? Should have posted this in that forum. Would you like me to move this thread over there ?

8 May 2009, 9:04 AM
Yes, that would be great. I'm sorry - I mean to post in that forum originally but I guess I got mixed up. Thank you very much.


10 May 2009, 6:37 AM
No, there is nothing you have to do. GXT handles everything for you.