1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    21
    Vote Rating
    0
    checks is on a distinguished road

      0  

    Default Destroy all components at once

    Destroy all components at once


    Hello,

    I want to destroy all components. I have an application that uses Log in and Log out, so when the user Logs out I need to destroy all windows that the user leaved active. The problem is that the application has a lot of windows son I don't want to do this...

    window1.destroy();
    window2.destroy();
    etc . . .

    Does sencha have a method to destroy all components at once???

    Thanks!!!!

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    7,190
    Vote Rating
    195
    scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold scottmartin is a splendid one to behold

      0  

    Default


    If you destroy the viewport, all items are destroyed as well. Containers automatically destroy all child items.

    Scott.

  3. #3
    Sencha User
    Join Date
    Mar 2009
    Location
    Fort Worth, TX
    Posts
    52
    Vote Rating
    1
    jemptymethod is on a distinguished road

      0  

    Default


    I question whether Scott's approach is what the OP wants, destroying the entire viewport -- that seems a bit drastic.

    Instead it appears that when a user logs out, they just want to destroy a number of windows the user may have open. My suggestion then is to store references to the open windows in a MixedCollection, or better yet a plain old Javascript object or array. Presuming that an array is used and it is named openWindows, then it would be a matter of something such as:

    Code:
    for (var i=0, n=openWindows.length; i<n; i++) {
        var openWindow = openWindows[i];
        if (openWindow) {
            openWindow.destroy();
        }
    }

  4. #4
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,170
    Vote Rating
    33
    jay@moduscreate.com is just really nice jay@moduscreate.com is just really nice jay@moduscreate.com is just really nice jay@moduscreate.com is just really nice

      0  

    Default


    Quote Originally Posted by scottmartin View Post
    If you destroy the viewport, all items are destroyed as well. Containers automatically destroy all child items.

    Scott.
    Window instances are generally not children of containers.

    Jay Garcia @ModusJesus || Modus Create co-founder
    Ext JS in Action author
    Sencha Touch in Action author

    Get in touch for Ext JS & Sencha Touch Touch Training

    We are also working on Video-based Sencha Touch training: Check it out here.

  5. #5
    Touch Premium Member
    Join Date
    Feb 2011
    Location
    NJ
    Posts
    253
    Vote Rating
    17
    droessner will become famous soon enough droessner will become famous soon enough

      0  

    Default


    How about this?

    Code:
    Ext.WindowManager.each(function(component) {
        if (component.getXType() === 'window') {
            component.destroy();
        }
    });

  6. #6
    Sencha User
    Join Date
    Mar 2009
    Location
    Fort Worth, TX
    Posts
    52
    Vote Rating
    1
    jemptymethod is on a distinguished road

      0  

    Default


    Quote Originally Posted by droessner View Post
    How about this?

    Code:
    Ext.WindowManager.each(function(component) {
        if (component.getXType() === 'window') {
            component.destroy();
        }
    });
    I like this better than mine.

  7. #7
    Sencha User
    Join Date
    Jul 2011
    Posts
    21
    Vote Rating
    0
    checks is on a distinguished road

      0  

    Default


    Excelent, I tried destroying viewport and it didn't work.
    now I'll try with the code below.

    Thanks to all of u..

  8. #8
    Sencha User
    Join Date
    Jul 2011
    Posts
    21
    Vote Rating
    0
    checks is on a distinguished road

      0  

    Default


    Ok, I tried with your code, and I get the error... Ext.WindowManager is undefined.

    So I have the next question:

    how should I use this code?
    Is 'component' a var????

    I use Extjs 3.1

  9. #9
    Sencha User
    Join Date
    Mar 2009
    Location
    Fort Worth, TX
    Posts
    52
    Vote Rating
    1
    jemptymethod is on a distinguished road

      0  

    Default


    In Ext 3 it would be Ext.WindowMgr (yet another change from 3 to 4 for no good reason: at least provide an alias for a while and mark WindowMgr as deprecated)

  10. #10
    Touch Premium Member
    Join Date
    Feb 2011
    Location
    NJ
    Posts
    253
    Vote Rating
    17
    droessner will become famous soon enough droessner will become famous soon enough

      0  

    Default


    Quote Originally Posted by jemptymethod View Post
    In Ext 3 it would be Ext.WindowMgr (yet another change from 3 to 4 for no good reason: at least provide an alias for a while and mark WindowMgr as deprecated)
    Ext.WindowMgr is still a valid alias in 4.x.