【问题标题】:ExtJs 4 grid is not populating with dataExtJs 4 网格未填充数据
【发布时间】:2011-06-12 11:57:23
【问题描述】:

我正在尝试使用 json 数据填充 Ext JS 4 Grid。不幸的是,无论我做什么,它仍然是空的。 JS函数如下:

function buildGrid() {

Ext.define('Contact', {
    extend: 'Ext.data.Model',
    fields: ['Id', 'Name', 'State', 'Age']
});

var store = Ext.create('Ext.data.Store', {
    model: 'Contact',
    proxy: {
        type: 'ajax',
        url: 'GridData',
        reader: {
            type: 'json',
            record: 'data',
            totalProperty: 'total'
        }
    }
});

var grid = Ext.create('Ext.grid.Panel', {
    store: store,
    columns: [
        { text: "Name", flex: 1, width: 120, dataIndex: 'Name', sortable: true },
        { text: "State", width: 100, dataIndex: 'State', sortable: true },
        { text: "Age", width: 115, dataIndex: 'Age', sortable: true },
    ],
    height: 210,
    width: 600,
    split: true,
    renderTo: Ext.getBody()
}).show();

}

Ext.onReady(buildGrid);

服务器响应如下:

{"callback":"1307878654818","total":1,"data":[{"Id":"ac2bedf1-bb5c-46e0-ba50-a6628341ca25","Name":"Smith","State":"NU","Age":24}]}

所以看起来没问题。但是网格视图没有显示日期。

任何人都可以看到我做错了什么?

【问题讨论】:

    标签: extjs extjs4


    【解决方案1】:

    您尚未指定根属性。试试

    reader: {
                type: 'json',
                root: 'data',
                totalProperty: 'total'
            }
    

    【讨论】:

    • 太棒了。就是这样!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-29
    • 2013-07-31
    • 2014-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多