extjs动态商店?

问题描述:

我试图建立一个应用程序使用临屋区MVC模式,虽然大多数事情都进展顺利,我遇到了新的架构问题。现在的问题在于,我已经创建了一个使用此商店的商店extjs动态商店?

Ext.define('MCMS.store.Items', { 
extend: 'Ext.data.Store', 
model: 'MCMS.model.Item', 
autoLoad: {'limit':10}, 
pageSize:10, 
remoteSort:true, 
proxy: { 
    url:'/ajax/moduleLoaded.php', 
    actionMethods: 'post', 
    extraParams :{'code': code,'toLoad':'latestContet','return':'json','module':Ext.getDom('module').value,'test':function(){console.log(this)}}, 
    type: 'ajax', 
    reader: { 
     type: 'json', 
     successProperty: 'success', 
     root: 'items' 

    } 
} 

});

这工作正常,但我需要模块参数是动态的,取决于使用它的视图。假设我有1格这样的

Ext.define('MCMS.view.items.List' ,{ 
extend: 'Ext.grid.Panel', 
alias : 'widget.itemsList', 
title : lang.items, 
store: 'Items', 
loadMask: true, 
columns: [ 
     {header: "#ID", width: 60, dataIndex: 'id', sortable: true,filter: {type: 'numeric'}}, 
     {header: "Title", width: 250, dataIndex: 'title', id:'title', sortable: true,filter: {type: 'string'}}, 
     {header: "Availability", width: 60, dataIndex: 'active', sortable: true,renderer: function(value, metaData, record, rowIndex, colIndex, store) { if (value == 1) { return '<span style="color:green;">' +lang.yes + '</span>'; } else { return '<span style="color:red;">' + lang.no + '</span>'; } }}, 
     {header: "Category", width: 200, dataIndex: 'category',sortable:false,renderer: function(value, metaData, record, rowIndex, colIndex, store) {       
      var cat = new Array; 
      Ext.each(value, function(person, index) { 
       cat.push('<a href="#showCat" class="catDetails" rel="'+ this.categoryid + '">' + this.category + '</a>'); 
      }); 
      return cat.join(' , '); }}, 
], 
selModel: Ext.create('Ext.selection.CheckboxModel'), 
columnLines: true, 
dockedItems: [ { 
     xtype: 'toolbar', 
     items: [{ 
      text:'Add Something', 
      tooltip:'Add a new row', 
      iconCls:'add', 
      itemId:'addItem' 
     }, '-', { 
      text:'Options', 
      tooltip:'Set options', 
      iconCls:'option' 
     },'-',{ 
      itemId: 'removeButton', 
      text:'Remove Something', 
      tooltip:'Remove the selected item', 
      iconCls:'remove', 
      disabled: true 
     }] 
    }], 
    bbar: {xtype: 'itemsPaging' }, 
    features: [filters], 

}); 我在3个或4个不同的场合使用这个网格,但数据需要根据它使用它的视图而改变。我需要的是一种以某种方式改变模块参数的方法。

如果我理解正确,您需要使用grid.reconfigure()来更改网格的组成并允许对其商店进行修改。

您可以设置extraParams直接

store.getProxy().extraParams.module = newValue; 

尝试使用此代码:

store.getProxy().extraParams.module = newValue; 
store.reload();