Extjs 4 MVC load class by widget name

I have a widget called AM.users.Tabswhere I expand tabPanel. How to load this tabPanel by widget name so that I can add tabs dynamically? I can install for it idand then use it Ext.getCmp('id').add({...}), but I would like to know if there is a way to get the component without the need for hard-coded identifiers, since I have aliases.

+3
source share
2 answers

How, how do you get a Component object?

If you do not want to use Ext.getCmp, you can use the new Component query system, which allows you to query components by id or xtype similar to css. http://dev.sencha.com/deploy/ext-4.0.0/docs/api/Ext.ComponentQuery.html

you can also query the parent component for child components using the same query system:

parentPanel.query('myxtype')
0
source

If you want to load your class by widget name, you can use Ext.createWidget()

For example, if tabPanel looks like this:

Ext.define('AM.users.Tabs', {
    extend: 'Ext.tab.Panel',
    alias: 'widget.userstabs',
    ...
});

You can call it like this:

Ext.createWidget('userstabs', {
    ...
    ...
});
0
source

All Articles