Aug 14, 2015, 7:13 PM
[CLOSED] How to iterate through the list of components efficiently?
Hi,
Could you suggest an efficient approach to iterating through the list of client side components on the page? In v1.7, I had a utility function (its purpose was to close all Notification windows) do it for me as below:
Could you suggest an efficient approach to iterating through the list of client side components on the page? In v1.7, I had a utility function (its purpose was to close all Notification windows) do it for me as below:
var hideNotifications = function () {
Ext.ComponentMgr.all.each(function (c) {
if (c.initialConfig && c.initialConfig.cls && c.initialConfig.cls.indexOf("x-notification") > -1) {
c.close();
}
});
};
Now, the aforementioned code snippet doesn't work under v3.2 due to certain breaking changes. I came up with the following replacement:var hideNotifications = function () {
Ext.ComponentMgr.each(function (c) {
var cmp = Ext.getCmp(c);
if (cmp.initialConfig && cmp.initialConfig.cls && cmp.initialConfig.cls.indexOf("x-notification") > -1) {
cmp.close();
}
});
};
While doing the trick, it leaves me concerned about performance penalties associated with getting a handle on every component object on the page in a loop. Can it be made more robust?
Last edited by Daniil; Aug 16, 2015 at 6:53 PM.
Reason: [CLOSED]