【问题标题】:Dojo Gridx with JsonStoreDojo Gridx 与 JsonStore
【发布时间】:2012-05-14 11:30:41
【问题描述】:

我正在尝试将 Gridx 网格连接到 JsonStore。代码和数据如下。问题是 Gridx 渲染正确,但它说:没有要显示的项目。有人知道我在做什么错吗? Dojo 和 Gridx 是用cpm 安装的最新版本。

编辑:Firebug/Chrom 开发工具中没有对 /test/ 的 ajax 请求

structure: [
        { field: 'id', name: 'Id' },
        { field: 'title', name: 'Title' },
        { field: 'artist', name: 'Artist' }
    ],

store: new JsonRestStore({
        idAttribute: 'id',
        target: '/test/'
    }),

/test 返回的数据是这样的:

{
    identifier: "id",
    label: "title",
    items: [
    {
        id: 1,
        title: "Title 1",
        artist: "Artist 1"
    },
    {
        id: 2,
        title: "Title 2",
        artist: "Artist 2"
    },
    ...
}

网格是通过以下方式创建的:

this.grid = new Grid({
    structure: structure,
    store: store,

    modules: [
        Pagination,
        PaginationBar,
    //Focus,
        SingleSort,
        ToolBar
    ],

    //paginationInitialPage: 3,
    paginationBarSizes: [10, 25, 50, 100],
    paginationBarVisibleSteppers: 5,
    paginationBarPosition: 'bottom'
}, this.gridNode);

【问题讨论】:

    标签: dojo dojo.gridx


    【解决方案1】:

    您是否指定了要使用的缓存?在您的情况下,它应该是异步缓存。

    require([
        'gridx/core/model/cache/Async',
       .....
    ], function(Cache, ...){
    
    this.grid = new Grid({
        cacheClass: Cache,
        ......
    });
    

    【讨论】:

      【解决方案2】:

      我发现当服务器没有在响应中返回 Content-Range 标头时会发生这种情况。显然商店不够聪明,无法仅计算返回数组中的项目...

      【讨论】:

      • 这是一个设计决策。很少使用 JSON 响应的功能,而是用于下载大数据
      猜你喜欢
      • 2013-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多