在商店中,我收到 JSON 响应,但仍然无法在网格中加载数据。
这是 JavaScript 代码:
prepare: function(){
// The store
this.store = new Ext.ux.app.data.Store({
directFn: Supplier.Hotelstock.Getcloseddate,
fields: [ 'stock_days', 'stock_datefrom' ],
autoLoad: false
});
var filters = {};
var allowedFilters = ['supplier_id'];
for(var i=0; i<allowedFilters.length; i++){
if (!Ext.isEmpty(this[allowedFilters[i]])){
filters[allowedFilters[i]] = this[allowedFilters[i]];
}
}
this.store.setBaseParam('filter', filters);
this.store.load();
//alert(this.store.data.first());
// The grid
this.grid = new Ext.ux.app.page.Grid({
store: this.store,
border: false,
autoResizeColumn: 1,
region: 'center',
columns: [
{
dataIndex: 'stock_days',
header: 'Days',
width: 40
},
{
dataIndex: 'stock_datefrom',
header: 'Closed Date',
width: 200,
sortable: true
}
]
});
this.setItems([this.grid]);
}
这是回应:
{
"tid": 9,
"type": "rpc",
"action": "Supplier_Hotelstock",
"method": "Getcloseddate",
"result": {
"results": 3,
"rows": [{
"stock_days": "Tue",
"stock_datefrom": "2013-08-06"
}, {
"stock_days": "Wed",
"stock_datefrom": "2013-08-07"
}, {
"stock_days": "Fri",
"stock_datefrom": "2013-08-16"
}],
"start": false,
"pageSize": false,
"metaData": {
"totalProperty": "results",
"startProperty": "start",
"root": "rows",
"fields": [{
"name": "stock_days",
"type": "string"
}, {
"name": "stock_datefrom",
"type": "string"
}]
}
}
}