Как загрузить данные в сетку extJS из JSONStore? - PullRequest
0 голосов
/ 19 октября 2011

У меня проблема с загрузкой данных из хранилища 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"}
]}

Пожалуйста, помогите!

Ответы [ 2 ]

1 голос
/ 20 октября 2011

Я не уверен, что это проблема, но конфигурация autoLoad неверна.

У вас есть: autoLoad=true

Должно быть: autoLoad : true

1 голос
/ 20 октября 2011

использовать 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
});
...