最好的答案是使用 MVVM 的概念创建一个 ViewModel
您在其中声明 Grid 的视图:
Ext.define('YourProject.View',{
requires : ['YourProject.Controller','YourProject.ViewModel'],
extend : 'Ext.form.Panel',
controller : 'MyController',
viewModel : 'MyViewModel',
initComponent : function(){
var me = this;
Ext.apply(me,{
xtype : 'grid',
itemId : 'myGrid',
});
};
});
ViewModel 中的 Store 示例:
Ext.define('YourProject.ViewModel',{
extend : 'Ext.app.ViewModel',
alias : 'MyViewModel',
//declare you stores here
stores : {
myStore : {
autoLoad : true,
fields : [{name : 'id', type : 'string'},
{name : 'value', type : 'string'}],
proxy : {
url : 'you/actionHere.do',
extraParams : {
yourParameter1 = 'paramVal',
yourParameter2 = 'paramVal2'
},
reader : {
type : 'json',
rootProperty : 'data',
totalPropert : 'total'
}
}
}
}
});
在控制器中使用存储:
Ext.define('YourProject.Controller',{
extend : 'Ext.app.ViewModel',
alias : 'myController',
applyState : function(){
var me = this;
//Get you store from ViewModel by doing this
var store = me.getView().getViewModel().getStore('dmlshFeeAmt');
me.getView().down(#'myGrid').setStore(store);
}
});
希望这可以帮助您的项目:)