Replacing Ext.reg() (xtype) in ExtJS4?

user568866 picture user568866 · Mar 21, 2011 · Viewed 17.1k times · Source

I want to use the MultiSelect from 3.3 in Ext JS 4, as described in this previous question:

Why are the Ext JS multiselect item selector files not included in the Ext JS 3.3 download and where are they?

It seems like the way to register xtypes has changed in Ext JS 4. When I try to import this widget,along with ItemSelector.js, I get an error on Ext.reg().

Ext.reg('multiselect', Ext.ux.form.MultiSelect);

//backwards compat
Ext.ux.Multiselect = Ext.ux.form.MultiSelect;

How do I change wdigets to get them to work in Ext JS 4?

Answer

Philip Guerrant picture Philip Guerrant · Apr 10, 2011

The Ext JS 4 way is to use the new class system to create your widget: http://www.sencha.com/blog/countdown-to-ext-js-4-dynamic-loading-and-new-class-system/

Make sure you assign your widget an alias using the "widget" namespace. For example:

Ext.define('Ext.ux.form.MultiSelect', {
    extend: 'ClassNameYouAreExtending',
    alias: 'widget.multiselect'
});

Then you can refer to the widget by the xtype 'multiselect'. When you use an xtype in Ext JS 4 it looks for a class with an alias of 'widget.[xtype]'.