-
30 Aug 2012 2:03 PM #1
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!!!!
-
30 Aug 2012 6:35 PM #2
If you destroy the viewport, all items are destroyed as well. Containers automatically destroy all child items.
Scott.
-
4 Sep 2012 9:54 AM #3
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 Sep 2012 10:12 AM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28

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.
-
4 Sep 2012 11:17 AM #5
How about this?
Code:Ext.WindowManager.each(function(component) { if (component.getXType() === 'window') { component.destroy(); } });
-
4 Sep 2012 11:55 AM #6
-
11 Sep 2012 1:59 PM #7
Excelent, I tried destroying viewport and it didn't work.
now I'll try with the code below.
Thanks to all of u..
-
11 Sep 2012 2:09 PM #8
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
-
14 Sep 2012 12:41 PM #9
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)
-
14 Sep 2012 1:02 PM #10



Reply With Quote
