gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 20:02:23 25 4
gpt4 key购买 nike

我在将数据从 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
});

关于javascript - 如何从 JSONStore 加载 extJS 网格中的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7826205/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com