Query for child component with a specific xtype

chriscrossweb picture chriscrossweb · Oct 8, 2014 · Viewed 17.1k times · Source

Is there a method to query for a child component of xtype 'yourxtype' ? For example you have a panel, and inside this panel is a custom xtype located on a toolbar.

The findParentByType works great for looking up, but there is not method like findChildByType. And the down method works only on elements. The Ext.ComponentQuery is a singleton, but not for xtypes? Is there another way to query from a component down?

Answer

Robert Watkins picture Robert Watkins · Oct 8, 2014

yourCt.down will find the first instance of a container with the specified type, in the component's children and descendants.

yourCt.child will do the same, but restrict to the direct children of the container.

yourCt.query will find all of the matching components underneath the container, as an array.

yourCt.up will find the first parent of the container that matches.

Oh, and Ext.ComponentQuery.query can take an optional object that is used as the start point for the query.

These are all based off (and clearly documented in) Ext.ComponentQuery