0

我正在使用 Dojo 1.6 来呈现一个简单的 DatGrid。我面临的唯一问题类似于dojo 1.6 DataGrid 无法显示列表? 这里的解决方案以及来自这里的参考http://dojotoolkit.org/documentation/tutorials/1.6/store_driven_grid/确实有效,但 JSON 结构仍然存在一个问题。以下是工作和非工作示例。我正在以格式获取 JSON,其中所有内容都包含在 items 数组中。我如何使它工作?

工作的 json 格式

[{
    "bolist": ["CHM", "CVO", "PMO"],
    "title": "How do I do",
    "painpoints": ["this", "that", "manay more"],
    "solution": "wondeful"
}, {
    "bolist": ["DGM", "EXE", "CLI"],
    "title": "There we go",
    "painpoints": ["Front", "back", "many other places"],
    "solution": "under review"
}]

不工作的 json 格式(我正在以这种格式获取我的 json)

{"items":[{
    "bolist": ["CHM", "CVO", "PMO"],
    "title": "How do I do",
    "painpoints": ["this", "that", "manay more"],
    "solution": "wondeful"
}, {
    "bolist": ["DGM", "EXE", "CLI"],
    "title": "There we go",
    "painpoints": ["Front", "back", "many other places"],
    "solution": "under review"
}]}
4

1 回答 1

0

您可以像处理 javascript 对象一样处理 json !所以尝试将 jsonReturn.items 传递到网格。这样,网格只获取您想要的 json 数据:

[{
    "bolist": ["CHM", "CVO", "PMO"],
    "title": "How do I do",
    "painpoints": ["this", "that", "manay more"],
    "solution": "wondeful"
}, {
    "bolist": ["DGM", "EXE", "CLI"],
    "title": "There we go",
    "painpoints": ["Front", "back", "many other places"],
    "solution": "under review"
}]
于 2013-02-18T11:53:46.720 回答