Javascript extjsxtype注册
我在extjs3.3.1中注册xtypes时遇到了一些问题 我想要一个有两个字符串字段的复合字段,但只显示一个 一些帮助将是很好的,因为我已经挣扎了很长一段时间,我不知道什么可能是错误的线索。 这是我的代码:Javascript extjsxtype注册,javascript,extjs3,Javascript,Extjs3,我在extjs3.3.1中注册xtypes时遇到了一些问题 我想要一个有两个字符串字段的复合字段,但只显示一个 一些帮助将是很好的,因为我已经挣扎了很长一段时间,我不知道什么可能是错误的线索。 这是我的代码: Ext.myApp.StringDouble = Ext.extend(Ext.form.CompositeField, { separator: '-', unitOptions: {}, values: ['first', 'second'], both
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);
谢谢。首先,我不明白为什么在将配置传递给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);
}
这些组件用作模板,可通过定义更改标签、单位、分隔符等进行修改,。。。。它们用于一些类似于库存的东西,其中许多项目具有相似的参数。