【问题标题】:dojo gridx wont read from JSONRest store - what am i missing here?dojo gridx 不会从 JSONRest 存储中读取 - 我在这里缺少什么?
【发布时间】: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


【解决方案1】:

gridx 和 dojox.grid.DataGrid 不是相同的东西。 dojox.grid.DataGrid 已弃用,仅适用于旧版 dojo/数据存储。您可以使用 dojo/data/ObjectStore 来使用 dojo/data API 包装一个 dojo/store 存储:

var teststore = new ObjectStore({ objectStore: new Store({ … }) });

但是,如果您要开始一个新项目,则应该改用 dgrid,它可以与 dojo/store 商店原生配合使用。

【讨论】:

  • 您好,我正在尝试使用 gridx 控件来做到这一点...只是找到一个好的示例非常困难...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-09-21
  • 2010-12-24
  • 2012-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多