How to find a child in a panel in ExtJs

How to find out if a specific child element (element) exists in the panel using the identifier of the child element.

Let's say I have a parent panel ( id = parentPanel ) and several panels as elements of this parent panel. Now I would like to search if the id panel ' childPanel09 ' is a child of the parent panel.

[Perhaps without using iteration]

Note: I am using ExtJs 3.4

+7
source share
2 answers

If you want to search only the direct children of the parentPanel, you can use getComponent :

 var childPanel = Ext.getCmp('parentPanel').getComponent('childPanel09'); if (childPanel) { alert('yes. child exists'); } 

If you want to search not only among direct children, but at any level under the parent panel, you can use find :

 var childPanel = Ext.getCmp('parentPanel').find('id', 'childPanel09')[0]; // [0] because find returns array if (childPanel) { alert('yes. child exists'); } 
+11
source

Ext.Container.find() (from the accepted answer) is different from ExtJS 3.4 (this is what asked the question). However, in ExtJS 4.0 and later, find() was removed in favor of Ext.Container.query () , which does the same thing.

+2
source

All Articles