ExtJS Grid не загружает данные - PullRequest
2 голосов
/ 09 апреля 2011

Я пытаюсь отобразить данные в сетке с помощью JsonStore.Сетка отображается, но не отображает данные.

Данные JSON, возвращаемые API.ashx:

[{"Account":{"Username":"root","Password":null,"Enabled":true,"Id":1},"Text":"Hallo Welt!","Id":1},{"Account":{"Username":"root","Password":null,"Enabled":true,"Id":1},"Text":"hihihi","Id":3}]

Мой код:

Ext.onReady(function () {
var store = new Ext.data.JsonStore({
    url: 'API.ashx?type=notes&action=getAll',
    root: 'Note',
    autoload: true,
    fields: ['Text', { name: 'Id', type: 'int'}]
});

var grid = new Ext.grid.GridPanel({
    store: store,
    columns: [
        {
            id: 'Note',
            header: 'Id',
            width: 25,
            sortable: true,
            dataIndex: 'Id'
        },
        {
            header: 'Text',
            width: 160,
            sortable: true,
            dataIndex: 'Text'
        }
    ],
    stripeRows: true,
    autoExpandColumn: 'Note',
    height: 350,
    width: 600,
    title: 'Notes',
    stateful: true,
    stateId: 'grid'
});

store.load();

grid.render('grid-example');
});

1 Ответ

3 голосов
/ 09 апреля 2011

Я просто исправил это сам. Пришлось убрать опцию «root» и теперь она отлично работает.

...