首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ExtJS xtype注册

ExtJS xtype注册
EN

Stack Overflow用户
提问于 2012-03-20 22:19:54
回答 1查看 506关注 0票数 0

我在ExtJS 3.3.1中注册xtype时遇到了一些问题。

我想要一个有两个字符串字段的合成域,但只显示了一个。

一些帮助会很好,因为我已经和它斗争了很长一段时间,我不知道哪里会出问题。这是我的代码:

代码语言:javascript
复制
Ext.myApp.StringDouble = Ext.extend(Ext.form.CompositeField, {
    separator: '-',
    unitOptions: {},
    values: ['first', 'second'],
    bothRequired: false,

    init: function() {
        this.items = [];
        var unitConf = {
        };

        Ext.apply(unitConf, this.unitOptions);
        this.items.push(new Ext.form.TextField(Ext.apply({
            name: this.values[0] + '.' + this.name,         
            fieldLabel: this.fieldLabel + ' ' + this.values[0],
                value: this.value && this.value[this.values[0]]
        }, unitConf)));

        this.items.push(new Ext.form.DisplayField({
            value: this.separator
        }));

        this.items.push(new Ext.form.TextField(Ext.apply({
            name: this.values[1] + '.' + this.name,         
            fieldLabel: this.fieldLabel + ' ' + this.values[1],
            value: this.value && this.value[this.values[1]]
    }, unitConf)));

},

initComponent : function() {
    this.init();
    Ext.form.TextField.superclass.init.Component.call(this);
}

});

Ext.reg('stringdouble', Ext.myApp.StringDouble);

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2012-03-21 02:23:29

首先,我不明白为什么您需要创建自己的组件,而将config传递给compositefield可以实现相同的行为,如下所示

代码语言:javascript
复制
{
    xtype: 'compositefield',
    labelWidth: 120
    items: [
        {
            xtype     : 'textfield',
            fieldLabel: 'Title',
            width     : 20
        },
        {
            xtype     : 'textfield',
            fieldLabel: 'First',
            flex      : 1
        }
    ]
}

而且在调用父类的initComponent方法时也会出现拼写错误

代码语言:javascript
复制
initComponent : function() {
    this.init();
    Ext.form.TextField.superclass.initComponent.call(this);
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9788595

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档