在 ExtJS4 中替换 Ext.reg() (xtype)? [英] Replacing Ext.reg() (xtype) in ExtJS4?
问题描述
我想在 Ext JS 4 中使用 3.3 中的 MultiSelect,如上一个问题所述:
为什么 Ext JS 多选项目选择器文件没有包含在 Ext JS 3.3 下载中?它们在哪里?
似乎在 Ext JS 4 中注册 xtypes 的方式发生了变化.当我尝试导入这个小部件和 ItemSelector.js 时,我在 Ext.reg() 上遇到错误.<代码>
<前>Ext.reg('multiselect', Ext.ux.form.MultiSelect);//向后兼容Ext.ux.Multiselect = Ext.ux.form.MultiSelect;如何更改 wdigets 以使其在 Ext JS 4 中工作?
Ext JS 4 的方式是使用新的类系统来创建您的小部件:http://www.sencha.com/blog/countdown-to-ext-js-4-dynamic-loading-and-new-class-system/
确保您使用小部件"命名空间为小部件指定别名.例如:
Ext.define('Ext.ux.form.MultiSelect', {扩展:'ClassNameYouAreExtending',别名:'widget.multiselect'});
然后您可以通过 xtype 'multiselect' 来引用小部件.当您在 Ext JS 4 中使用 xtype 时,它会查找别名为widget.[xtype]"的类.
I want to use the MultiSelect from 3.3 in Ext JS 4, as described in this previous question:
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?
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]'.
这篇关于在 ExtJS4 中替换 Ext.reg() (xtype)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!