2014-10-31 129 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/