我正在尝试在 Dojo 1.8 中获得 JsonRest 功能。工作加载DataGrid。我已经让 Dojo 客户端成功地与 REST 服务器通信。我拨打电话,我的 DataGrid 标题已填充,但未填充任何数据。来自 REST 调用的响应是……
{"data":{"fundId":"12345","fundDescription":"高风险股票基金","bidPrice":26.8,"offerPrice":27.4,"lastUpdated":"2013-01-23T14:13: 45"}}
我的 Dojo 代码是...
require([
"dojo/store/JsonRest",
"dojo/store/Memory",
"dojo/store/Cache",
"dojox/grid/DataGrid",
"dojo/data/ObjectStore",
"dojo/query",
"dojo/domReady!"
], function(JsonRest, Memory, Cache, DataGrid, ObjectStore, query) {
var restStore, memoryStore, myStore, dataStore, grid;
restStore = JsonRest({target:"http://localhost:8080/funds/12345"});
memoryStore = new Memory();
myStore = Cache(restStore, memoryStore);
grid = new DataGrid({
store: dataStore = new ObjectStore({objectStore: myStore}),
structure: [
{name:"Fund Id", field:"fundId", width: "200px"},
{name:"Description", field:"fundDescription", width: "200px"},
{name:"Bid Price", field:"bidPrice", width: "100px"},
{name:"Offer Price", field:"offerPrice", width: "100px"},
{name:"Last Updated", field:"lastUpdated", width: "200px"}
]
}, "target-node-id"); // make sure you have a target HTML element with this id
grid.startup();
query("#save").onclick(function(){
dataStore.save();
});
});
为了将数据成功加载到网格中,我缺少什么?