ExtJS网格不显示存储数据

ExtJS grid not showing store data

本文关键字:存储 数据 显示 网格 ExtJS      更新时间:2023-09-26

我的ExtJS网格没有显示我的存储数据。使用ExtJS 5

这是我的网格(它在一个hbox内):

{
    xtype: 'grid',
    title: 'Company Manager',
    id: 'companyGrid',
    flex: 1,
    plugins: 'rowediting',
    columnLines: true,
    store: Ext.data.StoreManager.lookup('companyStore'),
    columns: {
        items: [{
                header: 'ID',
                dataIndex: 'id',
            },
            {
                header: 'Name',
                dataIndex: 'name',
            },
            {
                header: 'Token',
                dataIndex: 'access_token'
            },
        ]
    }
}

这是我的商店(我使用Sencha的谷歌扩展,它充满了我的数据,所以这工作+结束});被编码块忽略):

var companyStore = Ext.create('Ext.data.Store', {
    storeId: 'companyStore',
    proxy: {
        type: 'ajax',
        url: 'resources/data/company.json',
        reader: {
            type: 'json',
            rootProperty: 'data'
        }
    },
    fields: [{
        name: 'id',
        type: 'int'
    }, {
        name: 'name',
        type: 'string'
    }, {
        name: 'access_token',
        type: 'string'
    }],
    autoLoad: true
});

有谁知道我哪里错了吗?

我试过:重新加载存储,检查存储是否实际填充,刷新网格视图。

我试过的都没用,所以我决定向你们征求意见:)

@Evan Trimboli

你让我思考了一下,我摸索了一下,找到了下面的解决方案。

不使用

store : Ext.data.StoreManager.lookup('companyStore'),

我用

bind : '{companyStore}',

并将定义存储移动到CompanyModel.js文件:)现在它可以正常工作!!!!

谢谢:D