2016-07-22 65 views
0

我想如下顯示在組合框中的值:組合框顯示爲空 - Ext.JS 4

Ext.define('Pgmtems.view.combo.DepoTurCombo', { 
      extend : 'Ext.form.field.ComboBox', 
      alias : 'widget.depoturcombo', 
      fieldLabel : 'Depo Cinsi', 
      displayField : 'aciklama', 
      valueField : 'value', 
      typeAhead : true, 
      forceSelection : true, 
      enableKeyEvents : true, 
      emptyText : '-Depo Cinsi-', 
      editable : false, 
      labelWidth : 70, 

      constructor : function(cfg) { 
       console.warn(cfg.xtype, " constructor arld."); 
       var me = this; 
       Ext.apply(this, cfg); 
       var store = Ext.create('Ext.data.Store', { 
          autoLoad : true, 
          fields : ['value', 'aciklama'], 
          data : [[3, "TL"], [2, "YTL"], [1, "ETL"]] 
         }); 
       Ext.apply(this, { 
          store : store 
         }); 
       this.callParent(arguments); 
      }, 
      initComponent : function() { 
       console.log('DepoTurCombo initComponent'); 
       this.trigger1Cls = 'x-form-clear-trigger'; 
       this.trigger2Cls = 'x-form-arrow-trigger'; 
       this.callParent(arguments); 
      }, 
      onTrigger1Click : function() { 
       this.clearValue(); 
      } 
     }); 

但是,它不顯示組合框的值。正如你所看到的,Depo Cinsi值是空的(實際上我可以看到3個項目,但是他們的名字沒有出現)。

關於如何解決這個問題的任何想法?

enter image description here

回答

3

使用Ext.data.ArrayStore而不是Ext.data.Store

小助手類,以使來自陣列數據創建Ext.data.Store這樣比較方便。 ArrayStore將自動配置爲​​。

工作例如:https://fiddle.sencha.com/#fiddle/1e2p


如果你想使用Ext.data.Store不使用​​你需要通過這樣的數據:

data: [{value: 3, aciklama: "TL"}, {value: 2, aciklama: "YTL"}, {value: 1, aciklama: "ETL"}] 
+0

謝謝您的回答,但我想要使用Ext.data.Store,因爲我將修改此示例以稍後從代理中讀取數據。 – supaplexy