我在ExtJS 3.3.1中注册xtype时遇到了一些问题。
我想要一个有两个字符串字段的合成域,但只显示了一个。
一些帮助会很好,因为我已经和它斗争了很长一段时间,我不知道哪里会出问题。这是我的代码:
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);谢谢。
发布于 2012-03-21 02:23:29
首先,我不明白为什么您需要创建自己的组件,而将config传递给compositefield可以实现相同的行为,如下所示
{
xtype: 'compositefield',
labelWidth: 120
items: [
{
xtype : 'textfield',
fieldLabel: 'Title',
width : 20
},
{
xtype : 'textfield',
fieldLabel: 'First',
flex : 1
}
]
}而且在调用父类的initComponent方法时也会出现拼写错误
initComponent : function() {
this.init();
Ext.form.TextField.superclass.initComponent.call(this);
}https://stackoverflow.com/questions/9788595
复制相似问题