关于Ext中JsonReader
时间:2010-09-27
来源:互联网
今天做了一个store,该store接受一个jsp返回的json,并用JsonReader读取,但无法将返回的数据读入store,求解。
Ext代码:
JScript code
jsp代码:
Java code
Ext代码:
JScript code
Ext.onReady(function(){ var _store = new Ext.data.Store({ autoLoad:true, proxy:new Ext.data.HttpProxy({url:"movie.jsp"}), reader:new Ext.data.JsonReader({root:"info"}, Ext.data.Record.create([{name:"name"}])) }); alert(_store.getCount()); })
jsp代码:
Java code
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%out.println("{success:true,info:[{'name':'zxy'}]}"); %>
作者: chungewudihehe 发布时间: 2010-09-27
高手帮忙
作者: chungewudihehe 发布时间: 2010-09-27
没人回答么?
作者: chungewudihehe 发布时间: 2010-09-27
格式不对,多了解一下jsonReader的格式
var myReader = new Ext.data.JsonReader({
// metadata configuration options:
idProperty: 'id'
root: 'rows',
totalProperty: 'results',
Ext.data.DataReader.messageProperty: "msg" // The element within the response that provides a user-feedback message (optional)
// the fields config option will internally create an Ext.data.Record
// constructor that provides mapping for reading the record data objects
fields: [
// map Record's 'firstname' field to data object's key of same name
{name: 'name'},
// map Record's 'job' field to data object's 'occupation' key
{name: 'job', mapping: 'occupation'}
]
});
This would consume a JSON data object of the form:
{
results: 2000, // Reader's configured totalProperty
rows: [ // Reader's configured root
// record data objects:
{ id: 1, firstname: 'Bill', occupation: 'Gardener' },
{ id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' },
...
]
}
var myReader = new Ext.data.JsonReader({
// metadata configuration options:
idProperty: 'id'
root: 'rows',
totalProperty: 'results',
Ext.data.DataReader.messageProperty: "msg" // The element within the response that provides a user-feedback message (optional)
// the fields config option will internally create an Ext.data.Record
// constructor that provides mapping for reading the record data objects
fields: [
// map Record's 'firstname' field to data object's key of same name
{name: 'name'},
// map Record's 'job' field to data object's 'occupation' key
{name: 'job', mapping: 'occupation'}
]
});
This would consume a JSON data object of the form:
{
results: 2000, // Reader's configured totalProperty
rows: [ // Reader's configured root
// record data objects:
{ id: 1, firstname: 'Bill', occupation: 'Gardener' },
{ id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' },
...
]
}
作者: zoujp_xyz 发布时间: 2010-09-27
不是格式的问题啊,我试了,还是那样。
作者: chungewudihehe 发布时间: 2010-09-27
谁给解答一下啊? 我都研究半天了
作者: chungewudihehe 发布时间: 2010-09-27
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28