我正在尝试使用带有 ExtJS 4.1(Sencha Architect 2)的 REST 代理,使用 CakePHP 读取 JSON 文件,该文件在 JSON 返回数据中具有视图。
此数据不仅包含对象,还包含相关对象、Book、BookCopy 等。
我应该如何创建商店和模型才能在 Grid 中使用 JSON?现在它在 Book 列的网格中显示对象,这是我在商店中创建的一个字段(我使用自动列将商店的字段映射到网格)。
这是 JSON(它是嵌套数据和相关数据):
[
{
"Book": {
"ISBN": "1660151266",
"title": "A Call to Arms ",
"author": "Loren L. Coleman ",
"pages": "44",
"book_copy_count": "10",
"book_available_count": "9",
"id": "66"
},
"BookCopy": [
{
"condition_id": "1",
"available": false,
"book_id": "66",
"id": "395",
"title": "A Call to Arms "
},
{
"condition_id": "1",
"available": true,
"book_id": "66",
"id": "396",
"title": "A Call to Arms "
},
{
"condition_id": "1",
"available": true,
"book_id": "66",
"id": "397",
"title": "A Call to Arms "
},
{
"condition_id": "1",
"available": true,
"book_id": "66",
"id": "398",
"title": "A Call to Arms "
},
{
"condition_id": "1",
"available": true,
"book_id": "66",
"id": "399",
"title": "A Call to Arms "
},
{
"condition_id": "1",
"available": true,
"book_id": "66",
"id": "400",
"title": "A Call to Arms "
},
{
"condition_id": "1",
"available": true,
"book_id": "66",
"id": "401",
"title": "A Call to Arms "
},
{
"condition_id": "1",
"available": true,
"book_id": "66",
"id": "402",
"title": "A Call to Arms "
},
{
"condition_id": "1",
"available": true,
"book_id": "66",
"id": "403",
"title": "A Call to Arms "
},
{
"condition_id": "1",
"available": true,
"book_id": "66",
"id": "404",
"title": "A Call to Arms "
}
]
},
{
"Book": {
"ISBN": "1003581858",
"title": "Call of Duty ",
"author": "Blain Lee Pardoe ",
"pages": "52",
"book_copy_count": "6",
"book_available_count": "5",
"id": "58"
},
"BookCopy": [
{
"condition_id": "1",
"available": false,
"book_id": "58",
"id": "350",
"title": "Call of Duty "
},
{
"condition_id": "1",
"available": true,
"book_id": "58",
"id": "351",
"title": "Call of Duty "
},
{
"condition_id": "1",
"available": true,
"book_id": "58",
"id": "352",
"title": "Call of Duty "
},
{
"condition_id": "1",
"available": true,
"book_id": "58",
"id": "353",
"title": "Call of Duty "
},
{
"condition_id": "1",
"available": true,
"book_id": "58",
"id": "354",
"title": "Call of Duty "
},
{
"condition_id": "1",
"available": true,
"book_id": "58",
"id": "355",
"title": "Call of Duty "
}
]
},
{
"Book": {
"ISBN": "1843871223",
"title": "Close Quarters ",
"author": "Victor Milan ",
"pages": "32",
"book_copy_count": "9",
"book_available_count": "9",
"id": "23"
},
"BookCopy": [
{
"condition_id": "1",
"available": true,
"book_id": "23",
"id": "139",
"title": "Close Quarters "
},
{
"condition_id": "1",
"available": true,
"book_id": "23",
"id": "140",
"title": "Close Quarters "
},
{
"condition_id": "1",
"available": true,
"book_id": "23",
"id": "141",
"title": "Close Quarters "
},
{
"condition_id": "1",
"available": true,
"book_id": "23",
"id": "142",
"title": "Close Quarters "
},
{
"condition_id": "1",
"available": true,
"book_id": "23",
"id": "143",
"title": "Close Quarters "
},
{
"condition_id": "1",
"available": true,
"book_id": "23",
"id": "144",
"title": "Close Quarters "
},
{
"condition_id": "1",
"available": true,
"book_id": "23",
"id": "145",
"title": "Close Quarters "
},
{
"condition_id": "1",
"available": true,
"book_id": "23",
"id": "146",
"title": "Close Quarters "
},
{
"condition_id": "1",
"available": true,
"book_id": "23",
"id": "147",
"title": "Close Quarters "
}
]
},
{
"Book": {
"ISBN": "1795387125",
"title": "D.R.T ",
"author": "James D. Long ",
"pages": "71",
"book_copy_count": "5",
"book_available_count": "5",
"id": "25"
},
"BookCopy": [
{
"condition_id": "1",
"available": true,
"book_id": "25",
"id": "156",
"title": "D.R.T "
},
{
"condition_id": "1",
"available": true,
"book_id": "25",
"id": "157",
"title": "D.R.T "
},
{
"condition_id": "1",
"available": true,
"book_id": "25",
"id": "158",
"title": "D.R.T "
},
{
"condition_id": "1",
"available": true,
"book_id": "25",
"id": "159",
"title": "D.R.T "
},
{
"condition_id": "1",
"available": true,
"book_id": "25",
"id": "160",
"title": "D.R.T "
}
]
},
{
"Book": {
"ISBN": "1401073348",
"title": "Dagger Point ",
"author": "Thomas Gressman ",
"pages": "46",
"book_copy_count": "10",
"book_available_count": "10",
"id": "48"
},
"BookCopy": [
{
"condition_id": "1",
"available": true,
"book_id": "48",
"id": "295",
"title": "Dagger Point "
},
{
"condition_id": "1",
"available": true,
"book_id": "48",
"id": "296",
"title": "Dagger Point "
},
{
"condition_id": "1",
"available": true,
"book_id": "48",
"id": "297",
"title": "Dagger Point "
},
{
"condition_id": "1",
"available": true,
"book_id": "48",
"id": "298",
"title": "Dagger Point "
},
{
"condition_id": "1",
"available": true,
"book_id": "48",
"id": "299",
"title": "Dagger Point "
},
{
"condition_id": "1",
"available": true,
"book_id": "48",
"id": "300",
"title": "Dagger Point "
},
{
"condition_id": "1",
"available": true,
"book_id": "48",
"id": "301",
"title": "Dagger Point "
},
{
"condition_id": "1",
"available": true,
"book_id": "48",
"id": "302",
"title": "Dagger Point "
},
{
"condition_id": "1",
"available": true,
"book_id": "48",
"id": "303",
"title": "Dagger Point "
},
{
"condition_id": "1",
"available": true,
"book_id": "48",
"id": "304",
"title": "Dagger Point "
}
]
}
]