繁体   English   中英

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

[英]How to load data in extJS grid from JSONStore?

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

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:

{"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"}
]}

请帮忙!

使用Ext.data.Store代替JsonStore,在4.0.2a中测试
我也找不到JsonStore的文档

尝试这个:

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
});

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

你有: autoLoad=true

它应该是: autoLoad : true

暂无
暂无

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

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