Dojo Gridx with JsonStore



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

编辑:Firebug/Chrom开发工具中没有Ajax对/test/

的要求
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);

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

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

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

最新更新