Shlomo
Shlomo

Reputation: 3990

ExtJs - How to remove all floating components

Using ExtJs 4.1

Is there a way to query all floating components (windows, message boxes, etc.)?

My aim is to remove (destroy) all floating objects. It would be sufficient to "get" them on the first hand.

Upvotes: 1

Views: 3550

Answers (1)

sra
sra

Reputation: 23973

Well simply do it by using the Ext.WindowManager which is responsible for all floating components by default.

Following should work:

Ext.WindowManager.each(function(cmp) { cmp.destroy(); });

Here's a example JSFiddle:

Ext.create('Ext.window.Window', {
    title: 'Hello',
    height: 200,
    width: 400,
    layout: 'fit',
    items: {  // Let's put an empty grid in just to illustrate fit layout
        xtype: 'grid',
        border: false,
        columns: [{header: 'World'}],                 // One header just for show. There's no data,
        store: Ext.create('Ext.data.ArrayStore', {}) // A dummy empty data store
    }
}).show();

Ext.Function.defer(function(){Ext.WindowManager.each(function(cmp) { cmp.destroy(); })}, 5000);

For further reading on DOM-Query

Edit destroy only defined types

For that case go with the xtype of the component and check it.

Ext.WindowManager.each(function(cmp) { if (cmp.xtype === 'window') cmp.destroy(); });

Upvotes: 4

Related Questions