我正在从我的 REST 接口提供的 JSON 数据构建一个 Dojo DataGrid。DataGrid 使用 QueryReadStore 很好地加载数据,但似乎不适用于通过管道传输到 JsonRestStore 的相同数据。
我在 Dojo 1.4.1 中使用以下 Dojo 库:
dojo.require("dojox.data.JsonRestStore");
dojo.require("dojox.grid.DataGrid");
dojo.require("dojox.data.QueryReadStore");
dojo.require("dojo.parser");
我以以下方式声明我的商店:
var storeJRS = new dojox.data.JsonRestStore({target:"api/collaborations.php/1"});
var storeQRS = new dojox.data.QueryReadStore({url:"api/collaborations.php/1", requestMethod:"get"});
我像这样创建我的网格布局:
var gridLayout = [
new dojox.grid.cells.RowIndex({ name: "Row #", width: 5, styles: "text-align: left;" }),
{
name: "Name",
field: "name",
styles: "text-align:right;",
width:20
},
{
name: "Description",
field: "description",
width:30
}
];
我创建我的 DataGrid 如下:
<div dojoType="dojox.grid.DataGrid" jsid="grid2" store="storeQRS" structure="gridLayout" style="height:500px; width:1000px;"></div>
以上工作,但如果我使用 QueryReadStore 作为我的存储,网格是用标题(名称,描述)创建的,但它没有填充任何行:
<div dojoType="dojox.grid.DataGrid" jsid="grid3" store="storeQRS" structure="gridLayout" style="height:500px; width:1000px;"></div>
使用 FireBug,我可以看到 QueryReadStore 正在从我的 REST 接口获取我的 JSON 数据。它如下所示:
{"numRows":6,"items":[{"name":"My Super Cool Collab","description":"This is for all the super cool people in the super cool group","id":1},{"name":"My Other Super Cool","description":"This is for all the other super cool people","id":3},{"name":"This is another coll","description":"This is just some other collab","id":4},{"name":"some new collab","description":"this is a new collab","id":5},{"name":"yet another new coll","description":"uh huh","id":6},{"name":"asdf","description":"asdf","id":7}]}
有任何想法吗?谢谢。