softwareplay
softwareplay

Reputation: 1409

can't load json data into a grid extjs

I tryed every answer i found (in Stackoverflow there are many) to solve my problem with the store of extjs, but still the data doesn't get displayed in the grid, even if the grid is correctly fisplayed. I'm confused so I'm writing the "store" I was able to build reading the answer on this site. I don't know why it's not loading the data into the grid. If you need more information to help please ask.

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'
    }
}

})

The grid is loaded in a new window through an ajax call. The code of the new window is the following:

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'
        }],

I do have the impression that the part with the columns is not read by ext.js, cause it doesn't index the name and id of the data i'm passing to it in the json.

Upvotes: 0

Views: 1381

Answers (1)

softwareplay
softwareplay

Reputation: 1409

The solution was so simple that I'm embarrassed to say it.

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

Instead of:

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

Upvotes: 1

Related Questions