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?
yourCt.down
will find the first instance of a container with the specified type in child components and descendants.
yourCt.child
will do the same, but will be limited to the direct children of the container.
yourCt.query
will find all matching components under the container as an array.
yourCt.up
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.
Ext.ComponentQuery.query('fieldxtype')
This only returns one instance i.e. if we have 5 instances of xtype.it then only the first instance of xtype will be returned.
formpanel.down('fieldxtype')
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.