2012-03-20 8 views
0

ExtJS 3.3.1でxtypesを登録する際に問題があります。ExtJS xtype登録

2つの文字列フィールドを持つ複合フィールドが必要ですが、1つしか表示されません。

私はかなりの時間それに苦労していると私は間違っているかもしれない手がかりを持っていないいくつかの助けがいいだろう。 これは私のコードです:

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); 

ありがとうございました。すべての最初の

答えて

0

この

{ 
    xtype: 'compositefield', 
    labelWidth: 120 
    items: [ 
     { 
      xtype  : 'textfield', 
      fieldLabel: 'Title', 
      width  : 20 
     }, 
     { 
      xtype  : 'textfield', 
      fieldLabel: 'First', 
      flex  : 1 
     } 
    ] 
} 

のように、同じ動作を実現することができますcompositefieldに設定を渡すときに、独自のコンポーネントを作成する必要があり、また、親クラスを呼び出すタイプミスがあり、なぜ私は理解していないinitComponent方法

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

これらのコンポーネントは、定義(変更ラベル、ユニット、分離器、...)によって修飾することができるテンプレートとして機能します。それらは、多くの品目が類似のパラメータを有する在庫保管のようなものに使用される。 – Zhack