Request for a child component with a specific xtype

Is there a method to request the child component xtype 'yourxtype'? For example, you have a panel and inside that panel is a custom xtype located in the toolbar.

The findParentByType function is great for searching, but there is no method like findChildByType. And the down method only works on elements. Ext.ComponentQuery - singleton but not for xtypes? Is there any other way to request from component downward?


source to share

4 answers


will find the first instance of a container with the specified type in child components and descendants.


will do the same, but will be limited to the direct children of the container.


will find all matching components under the container as an array.


will find the first parent container that matches.

Oh, and Ext.ComponentQuery.query

can take an optional object that is used as a starting point for the request.

They are all based on (and clearly documented) by Ext.ComponentQuery



There is also a method down

for component requests, but this is only available for containers. And component requests appear in xtypes for identifiers without a prefix (like "#", "." Etc.). It doesn't matter if the xtype is defined by Ext or your self. So do:

var child = yourCt.down('yourxtype');




This worked for me

This returns an array of instances with a mention of xtype.



This only returns one instance i.e. if we have 5 instances of then only the first instance of xtype will be returned.



if you want to get a component by name you can use

 var componentArray = Ext.ComponentQuery.query('[name=checkboxName]');

 var componentObj = Ext.ComponentQuery.query('[name=checkboxName]')[0];




You can simply request using Ext.ComponentQuery.query('myXtype')

this will return an array of all instances of your type.



All Articles