[英]ExtJS xtype registering
我在ExtJS 3.3.1中注冊xtype遇到麻煩。
我想要一個帶有兩個字符串字段的Compositefield,但只顯示一個。
一些幫助會很不錯,因為我已經為之奮斗了很長時間,而且我不知道可能出什么問題。 這是我的代碼:
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);
謝謝。
首先,我不明白為什么在將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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.