ExtJS hide all child components [duplicate]

2019-08-17 06:35发布

This question already has an answer here:

Consider:

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

Is there a better way?

1条回答
小情绪 Triste *
2楼-- · 2019-08-17 06:54

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.

查看更多
登录 后发表回答