2014-10-31 73 views
0

我創建了組合字段。該字段的商店從另一個加載。我在這裏給幾個代碼。Extjs在加載後在組合框存儲中添加選項

initComponent:function() 
    { 
     var me = this; 

     this.contentType = Ext.create('AA.com.Planner.form.combo.ContentType',{ 
      architectOnly: true, 
      name: 'content_type_id', 
      allowBlank: false, 
      disabled: true, 
      listeners: { 
       change: function(checkbox, newValue, oldValue){ 
        if(newValue){ 
         var contentTypeRecord = checkbox.findRecordByValue(newValue); 
         // for the order by field 
         me.orderBy.getStore().getProxy().setExtraParam('content_type_id',newValue); // I would like to add another option here 
         me.orderBy.getStore().load(); 
         me.orderBy.enable(); 


        }else{ 

         me.orderBy.disable(); 
         me.orderBy.setValue(''); 

        } 
       } 
      }, 
      plugins: [{ 
       ptype: 'clearvalue' 
      }] 
     }); 

    } 

}); 

我想用me.orderBy.getStore()添加另一個選項。

+1

嘿...你要添加其他額外的PARAM或要附加記錄添加到您的商店? – Sreek521 2014-10-31 07:04:00

+0

嘗試將回調放入load()函數中,然後添加它。這樣你就擁有了現有的商店,並且你可以爲它添加一條記錄。添加後請確保它不髒。不要放棄你,但是從服務器添加它而不是客戶端更好?在事實之後需要添加它的原因是什麼? – MacGyver 2014-10-31 07:05:42

+0

Sreek521,我想添加額外的記錄到您的商店,以便我可以得到它的組合.. – 2014-10-31 07:09:42

回答

0

也許最簡單的方法是在加載事件處理程序中添加新的記錄:

Ext.create('Ext.data.Store', { 
    [...], 

    listeners: { 
     load: function(store) { 
      store.add({ name: 'Dummy' }); 
     } 
    } 
}); 

小提琴:http://jsfiddle.net/kqpq25hL/3/