简体   繁体   English

ExtJs4:将json数据加载到网格中

[英]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? 问题,根属性是json的三个节点,应该被读取吗? 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. 因为网格列的名称是应该在json文件中读取的该节点的字段的名称。 The json file is below but i suggest you to read with this viewer . json文件在下面,但我建议您使用此查看器阅读。

The json . json

Agnese Agnese

To begin with, the root is incorrect. 首先,根目录不正确。 It should be response.platform_members . 它应该是response.platform_members

Also, the model name is a class name, so it should be PlatformMember . 此外,模型名称是类名称,因此它应该是PlatformMember

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM