有没有办法将ExtJs gridpanel的JSON存储作为二维数组发送到Controller。 提前谢谢。
答案 0 :(得分:1)
要从商店获取一系列记录,您可以使用:
var store = gridpanel.getStore();
var records = store.getRange();
// If you don't want any of that metadata referring to the gridpanel.
var rawRecords = records.map(function(r) {return r.data;});
要将其传递给控制器,最佳做法是从网格面板触发事件并让控制器监听它。
// Somewhere in gridpanel or a reference to whatever your custom class is
gridpanel.fireEvent('rawRecordsEvent', rawRecords);
...
// In controller
Ext.define('MyApp.controller.GridController', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
// gridpanel or alias of whatever your custom class is.
'gridpanel': {
rawRecordsEvent: this.onRawRecordsEvent
}
});
},
onRawRecordsEvent: function(rawRecords) {
console.log(rawRecords);
}
});
以下是如何使用控制器监听视图组件的一个很好的示例: http://www.objis.com/formationextjs/lib/extjs-4.0.0/docs/api/Ext.app.Controller.html
答案 1 :(得分:0)
我认为你可以使用baseParams选项发送你需要的任何参数。 E.g:
var store = new Ext.data.JsonStore({
baseParams: {some_array: [['1'],['2']]},
...