首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从JSONStore加载extJS网格中的数据?

如何从JSONStore加载extJS网格中的数据?
EN

Stack Overflow用户
提问于 2011-10-20 02:28:52
回答 2查看 9.4K关注 0票数 0

我在将数据从JSON存储加载到EXT网格时遇到问题。代码如下:

代码语言:javascript
复制
var store = new Ext.data.JsonStore({
        root: 'rates',
        autoLoad=true,
        fields: ['mainid','Country'],
        proxy : new Ext.data.HttpProxy({
                 method: 'GET',
                 url: '/projectLink/gridData.php'
            })
    });

    var grid = Ext.create('Ext.grid.Panel',{
                    renderTo: 'grid-rates',
                    width:700,
                    height:500,
                    title:"Country",
                    store:store,
                    columns:[
                                {id: 'mainid', header: "mainid", width: 200, sortable: true, dataIndex: 'mainid'},
                                {id: 'Country', header: "Country", width: 200, sortable: true, dataIndex: 'Country'}
                             ]

                });

JSON存储被填满,因为它向服务器发送请求,数据被发回,但网格永远不会被填充:(缺少什么?

遵循我使用的JSON:

代码语言:javascript
复制
{"count":"18239",
"rates":[
{"mainid":"75966","Country":"Afghanistan Cellular-AT"},
{"mainid":"75967","Country":"Afghanistan Cellular-AWCC"},
{"mainid":"75968","Country":"Afghanistan Cellular-Areeba"},
{"mainid":"75969","Country":"Afghanistan Cellular-Etisalat"},
{"mainid":"75970","Country":"Afghanistan Cellular-Others"},
{"mainid":"75971","Country":"Afghanistan Cellular-Roshan"},
{"mainid":"75972","Country":"Albania"},
{"mainid":"75973","Country":"Albania Cellular-AMC"},
{"mainid":"75974","Country":"Albania Cellular-Eagle"},
{"mainid":"75975","Country":"Albania Cellular-Plus"}
]}

请帮帮我!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-10-20 11:11:15

使用4.0.2a中测试的Ext.data.Store代替JsonStore

我在文档里也找不到JsonStore

试试这个:

代码语言:javascript
复制
var store = new Ext.data.Store({ 
    fields:['mainid','Country'],
    proxy: {
        type: 'ajax',
        url : '/projectLink/gridData.php',
        reader: {
            type: 'json',
            root: 'rates',
            totalProperty : "count"
        }
    },
    autoLoad : true
});
票数 1
EN

Stack Overflow用户

发布于 2011-10-20 19:51:40

我不确定这是否是问题所在,但是配置autoLoad是错误的。

你有:autoLoad=true

应该是:autoLoad : true

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7826205

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档