【发布时间】:2013-11-27 18:13:42
【问题描述】:
我无法从 JsonRest 商店填充 gridx 小部件。请参阅下面的代码... test1.json 包含的信息与我在 teststore 的数据中指定的信息相同。
当我将网格更改为指向 teststore var 时,它会正确显示内容,但是当我将其指向 reststore 变量时,我会收到“没有要显示的项目”消息。
有人知道我错过了什么吗?
var restStore = new dojo.store.JsonRest({target:"http://localhost:9081/MyProj/test1.json"});
var teststore = new Store({
data: [
{id: "1", "description":"First Description"},
{id: "2", "description":"Second Description"},
{id: "3", "description":"Third Description"},
{id: "4", "description":"Fourth Description"}
]
});
grid = new Grid({
cacheClass: Cache,
store: restStore,
structure: [
{id: "description", field: 'description', width: '100%'}
]
});
grid.startup();
【问题讨论】:
-
您尝试过使用实际服务还是仅使用静态 JSON 端点?该端点可能不会像 dojo/store/JsonRest 期望的那样设置 Content-Range 标头,因此这可能是问题的一部分...有关更多信息,请参阅dojotoolkit.org/reference-guide/1.9/quickstart/rest.html。
-
另请注意,您需要使用
Async缓存 (gridx/core/model/cache/Async)。 -
它是一个静态端点....感谢您的链接...有没有什么快速的方法来设置内容范围标题,以便我可以看到它与静态 json 一起使用?...
-
嗨,肯....成功了...谢谢!
标签: dojox.grid.datagrid dojox.grid dojo