新手刚刚学习ExtJs 建立了一个简单的表格 大家看一下有什么错误呢? 一直都报json语法错误
下面是ext代码:Ext.require(['*']);
var a = document.documentElement.clientWidth;
var b = document.documentElement.clientHeight;
Ext.onReady(function(){
//模型
Ext.define('exec', {
extend: 'Ext.data.Model',
fields: ['id', 'name', 'email']
}); //获取数据源
var store = new Ext.data.Store({
model: 'exec',
proxy: {
type: 'ajax',
url : 'exec.json',
reader: {
type: 'json',
model:'exec'
}
},
autoLoad: true
});
//grid panel
Ext.create('Ext.grid.Panel',{
title:'测试表格1',
store: store,
columns:[
{text:'id',dataIndex:'id'},
{text:'name',dataIndex:'name'},
{text:'email',dataIndex:'email'} ],
width:a,
height:b,
renderTo: Ext.getBody()
});
});exec.json:
[
{"id": 1,"name": "Ed Spencer","email": "[email protected]"},
{"id": 2,"name": "Abe Elias","email": "[email protected]"}
]哪里出错了 求大家给帮忙找找
下面是ext代码:Ext.require(['*']);
var a = document.documentElement.clientWidth;
var b = document.documentElement.clientHeight;
Ext.onReady(function(){
//模型
Ext.define('exec', {
extend: 'Ext.data.Model',
fields: ['id', 'name', 'email']
}); //获取数据源
var store = new Ext.data.Store({
model: 'exec',
proxy: {
type: 'ajax',
url : 'exec.json',
reader: {
type: 'json',
model:'exec'
}
},
autoLoad: true
});
//grid panel
Ext.create('Ext.grid.Panel',{
title:'测试表格1',
store: store,
columns:[
{text:'id',dataIndex:'id'},
{text:'name',dataIndex:'name'},
{text:'email',dataIndex:'email'} ],
width:a,
height:b,
renderTo: Ext.getBody()
});
});exec.json:
[
{"id": 1,"name": "Ed Spencer","email": "[email protected]"},
{"id": 2,"name": "Abe Elias","email": "[email protected]"}
]哪里出错了 求大家给帮忙找找
解决方案 »
- jquery.uploadify上传图片问题
- myeclipse中weblogic启动出错,但是weblogic能单独启动,急急!!
- 为img绑定onload事件问题
- 请教~csdn社区中心右下角的div是如何实现的就是聊天窗口所在的那一行
- var floatVal = .33 * 10;的结果为什么是3.3000000000000002 呢?
- 更改背景图片的js代码错,谢谢!!
- 下拉列表 关联显示的时候出问题啦~~ 在线等
- 动态表格如何合并
- 50求救:如何可以获取远程页面内容(而不是页面源代码)并且保存到一个txt文本中呢?
- 这是..cnzz统计被黑的节奏?那得有多少人中招?
- 在JSP中插入图片
- datepicker修改为日程表的问题
var store = new Ext.data.Store({
model: 'exec',
proxy: {
type: 'ajax',
url : 'exec.json',
reader: {
type: 'json',
root:'data'//这里应该是个root吧
}
},
autoLoad: true
});
columns:[
{header:'id',dataIndex:'id'},
{header:'name',dataIndex:'name'},
{header:'email',dataIndex:'email'}///应该是header吧 ]
data:[
{"id": 1,"name": "Ed Spencer","email": "[email protected]"},
{"id": 2,"name": "Abe Elias","email": "[email protected]"}
]///data在你返回的json数据里
model: 'exec',
data:[
{"id": 1,"name": "Ed Spencer","email": "[email protected]"},
{"id": 2,"name": "Abe Elias","email": "[email protected]"}
]
});header 好像和text 效果一样 应该没错
{"id": 1,"name": "Ed Spencer","email": "[email protected]"},
{"id": 2,"name": "Abe Elias","email": "[email protected]"}
]
这个是数组!改成这样:
{
"name":"whatever",
"content":[{"id": 1,"name": "Ed Spencer","email": "[email protected]"},{"id": 2,"name": "Abe Elias","email": "[email protected]"}]
}
还有如二楼所说root要选对,这里应该是"content"
这样好像也不行 说什么未组织好。 root那边我也改过了 header我也改过了 好是没法读取。 是不能这样读取XX.json 文件吗 我看官方的文档 应该可以这样啊。