【发布时间】:2012-03-07 06:57:20
【问题描述】:
使用 sencha touch 2,我尝试使用 json 代理呈现嵌套列表。 json看起来像
[
{
"start": "0"
},
{
"format": "json"
},
.......
{
"GetFolderListing": [
{
"folder": {
"total": 0,
"id": "Calendar",
"name": "Calendar",
"unread": 0,
}
},
{
"folder": {
"total": 0,
"id": "Contacts",
"name": "Contacts",
"unread": 0,
}
},
.......
我想使用 GetFolderListing.folder.name 作为 displayField 我的商店看起来像
Ext.define('foo.store.FolderListing', {
extend: 'Ext.data.TreeStore',
require: ['foo.model.FolderListing'],
config: {
model: 'foo.model.FolderListing',
recursive: true,
proxy: {
type: 'jsonp',
url: 'http://localhost/?xx=yy&format=json',
callbackKey: "jsoncallback",
reader: {
type: 'json',
rootProperty: 'GetFolderListing',
record: 'folder'
}
}
}
});
现在我得到的只是一个错误 未捕获的类型错误:无法读取未定义的属性“id”
谁能提供有关如何解决此问题或更好地调试它或如何进行自定义解析并将商品传回商店的见解?
谢谢
======== 更新 - 为了让 rootProperty 在阅读器中工作,json 必须是 jsonobject 而不是 json 数组,例如
{
"GetFolderListing": [
{
"folder": {
"total": 0,
"id": "Contacts",
"name": "Contacts",
"unread": 0,
"leaf": "true"
}
},
{
"folder": {
"total": 0,
"id": "Conversation Action Settings",
"name": "Conversation Action Settings",
"unread": 0,
"leaf": "true"
}
},
.......
【问题讨论】:
标签: sencha-touch sencha-touch-2