1. #1
    Ext User
    Join Date
    Apr 2009
    Posts
    41
    Vote Rating
    0
    jhudson888 is on a distinguished road

      0  

    Default how to properly remove a panel

    how to properly remove a panel


    Hello,

    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

  2. #2
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,963
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Thumbs up


    If you are not creating custom classes (extending), you'll may want to use the simple 'beforedestroy' listeners to handle specific cleanup tasks.

    Code:
    somePanel.add({
       id : 'test',
       title: 'Test',
       setSomeRefs : function(){
          this.canvasEl = this.body.dom;  //important to cleanup these DOM references up
    
       },
       listeners:{
          render : function(){ this.setSomeRefs() },
          beforedestroy : function(){
              this.canvasEl = null;
         }
       }
    });
    
    somePanel.rendered && somePanel.doLayout();  //always call if the Container is already rendered.
    Then later:
    Code:
    somePanel.remove('test',true); //forceful destruction
    somePanel.doLayout();
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  3. #3
    Ext User
    Join Date
    Apr 2009
    Posts
    41
    Vote Rating
    0
    jhudson888 is on a distinguished road

      0  

    Default


    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

  4. #4
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,963
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Question


    Ah, GXT User ? Should have posted this in that forum. Would you like me to move this thread over there ?
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  5. #5
    Ext User
    Join Date
    Apr 2009
    Posts
    41
    Vote Rating
    0
    jhudson888 is on a distinguished road

      0  

    Default


    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.

    Joe

  6. #6
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    No, there is nothing you have to do. GXT handles everything for you.

Thread Participants: 2