0
使用sencha touch 2,我试图使用json proxy呈现嵌套列表。 JSON的样子Sencha Touch JSONPReader
[
{
"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'
}
}
}
});
现在我得到的是一个错误 遗漏的类型错误:无法读取property'id'undefined
任何人都可以提供关于如何解决这个问题或更好地调试的见解,或者如何进行自定义分析并将项目传回商店?
由于
======== 更新 - 为了使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"
}
},
.......
是的,你是对的,JSON需要为第一组兄弟姐妹映射寻址以使rootProperty工作。谢谢 ! – pjaol 2012-02-16 03:15:15