无法将 JSON 数据加载到网格扩展中



我尝试了我找到的每一个答案(在 Stackoverflow 中有很多)来解决我在 extjs 存储方面的问题,但数据仍然没有显示在网格中,即使网格被正确分割。我很困惑,所以我正在写我能够建立的"商店"阅读这个网站上的答案。我不知道为什么它没有将数据加载到网格中。如果您需要更多信息来提供帮助,请询问。

store: Ext.create('Ext.data.Store', {
    autoLoad: true,
    storeId: 'StoreName',
    fields: ['id','name'],
    data : JsonObject,
    model: 'ModelName',
    proxy: {
        type: 'memory',
        reader: {
        type: 'json',
        record: 'JsonRoot'
    }
}

})

网格通过 ajax 调用加载到新窗口中。新窗口的代码如下:

Ext.create('Ext.window.Window', {
                    title: 'GridTitle',
                    height: 200,
        width: 400,
        layout: 'fit',
        items: {  
        xtype: 'grid',
                    border: false,
        columns: [
                    {
            text     : 'id',
                            flex     : 1,
            sortable : true,
            dataIndex: 'id'
        },
        {
                text     : 'name',
            width    : 300,
            sortable : true,
            dataIndex: 'name'
        }],

我确实觉得带有列的部分没有被 ext.js 读取,因为它没有索引我在 json 中传递给它的数据的名称和 id。

解决方案非常简单,以至于我不好意思说出来。

reader: {
         type: 'json',
     root: 'jsonRoot'
        }

而不是:

reader: {
         type: 'json',
     record: 'jsonRoot'
        }

最新更新