Search code examples
extjsextjs4.2

ExtJS hide all child components


Consider:

Ext.Array.each(myContainer.query('> *'), function(cmp) { cmp.hide(); });

Is there a better way?


Solution

  • Your approach uses a query which takes more resources. A more efficient way may be just:

    Ext.each(myContainer.items.items, function(cmp) { cmp.hide(); });
    

    Since you already have a reference to myContainer, there's no point of querying for its children as you already have access to them.

    If you want it even more efficient, you can also write your own for loop and iterate across myContainer.items.items.