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}]}
何か案は?ありがとう。