softwareplay
softwareplay

Reputation: 1409

ExtJs4: loading json data into a grid

i've seen there are many question about this argument but anyone has an answer that fits for me. So let's dig into the code:

Ext.define('Platform Member', {
    extend: 'Ext.data.Model',
    fields: [
       {name: 'id'},
       {name: 'name',      type: 'string', convert: null,     defaultValue: undefined},
       {name: 'email',     type: 'string', convert: null,     defaultValue: undefined},
    ],
    idProperty: 'id'
});

This is the grid, it is recognized and the grids are in the webpage.

 var store = Ext.create('Ext.data.JsonStore', {
     autoLoad: true,
     model: "Platform Member",
     proxy: {
         type: 'ajax',
         url: '../static/platform-member.json',
         reader: {
             type: 'json',
             root: 'response/platform_members'
         }
     }
});

Question, is the root attribute the node of the json three which should be read? Cause the names of the grid's columns are the names of the fields of this node that should be read in the json file. The json file is below but i suggest you to read with this viewer.

The json.

Agnese

Upvotes: 0

Views: 165

Answers (1)

Evan Trimboli
Evan Trimboli

Reputation: 30082

To begin with, the root is incorrect. It should be response.platform_members.

Also, the model name is a class name, so it should be PlatformMember.

Upvotes: 1

Related Questions