簡體   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