0

在商店中,我收到 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"
            }]
        }
    }
}
4

1 回答 1

0

你不加载你的数据:

Ext.create('Ext.data.Store', {...

?

您将商店的参数放在哪里?我使用具有代理类型内存的存储,并且我在加载数据时遇到了同样的问题。如果您想完整调用用于存储的方法,请查看 Sencha 文档。

于 2013-09-17T14:02:05.903 回答