nameusernet 2013-06-09 23:30
浏览 269
已采纳

Extjs Store的Reader的root属性为什么不能是子属性?

我的Store是这么定义的:

Ext.define("NP.store.Menus", {
extend : "Ext.data.TreeStore",
model : "NP.model.Menu",
root : {
expanded : true,
text : "系统菜单",
},
proxy : {
type : "rest",
url : "menu",
reader : {
type : "json",
root : "data",//这里如果设置成data.content就不对
successProperty : "success"
}
}
});

服务器返回的JSON数据格式为:

{
    "data": {
        "content": [
            {
                "id": 1,
                "name": "系统管理",
                "url": null,
                "title": "系统管理",
                "icon": null,
                "parent": null,
                "children": [],
                "roles": [],
                "userGroups": []
            }
        ]
    },
    "success": true
}

因为我的模型数据集合是在数据的data.content里,而如果Store.proxy.reader.root设置成data.content 就会报错:Uncaught TypeError: Cannot read property 'content' of undefined

这是什么原因啊 ? 请指点啊

 

  • 写回答

1条回答 默认 最新

  • leehuat 2013-06-10 10:43
    关注

    [code="java"]
    这个应该解析json的问题吧。 你设置
    record: 'content' 试试吧。
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?