当前位置:编程学习 > JAVA >>

JsonStore读取外部文件的问题

我新建了一个json文件info.json,里面写的是一个json数据对象。如何用JsonStore读取啊!我的代码如下
var store = new Ext.data.JsonStore({
proxy:new Ext.data.HttpProxy({
url:'infos.json'
}),
reader:new Ext.data.JsonReader({
root:'infos',
fields: [  
{name: 'id'},   
{name: 'name'},   
{name: 'age'},   
{name: 'sex'},
{name: 'address'}
]
}),
});
store.load();
      var grid = new Ext.grid.GridPanel({  
width:500,  
height:300,  
title:'Students',  
store: store,  
columns:[{  
header: "Id",  
dataIndex: 'id',  
width: 220,  
sortable: false 
},{  
header: "Name",  
dataIndex: 'name',  
width: 100,  
sortable: false 
},{  
header: "Age",  
dataIndex: 'age',  
width: 70,  
align: 'right',  
sortable: false 
},{  
header: "Sex",  
dataIndex: 'sex',  
width: 150,  
sortable: false 
},
{  
header: "Address",  
dataIndex: 'address',  
width: 150,  
sortable: false 
}] 
}); 
不能显示出数据   求指教啊 ExtJS --------------------编程问答-------------------- JsonStore的默认reader是JsonReader。而不需要你重新在里面定义。所以,如果里面要用reader:new Ext.data.JsonReader的格式,外面的JsonStore就改成Store。如果外边用JsonStore的格式。里面直接写fields。不用JosnReader。 --------------------编程问答-------------------- 顶一下 --------------------编程问答-------------------- 谢谢你的回答! --------------------编程问答-------------------- 1楼说的有道理,你还要注意一点,你的json格式要范围哟。
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,