2

我正在尝试将 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);
4

2 回答 2

1

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

require([
    'gridx/core/model/cache/Async',
   .....
], function(Cache, ...){

this.grid = new Grid({
    cacheClass: Cache,
    ......
});
于 2012-05-28T02:09:57.893 回答
1

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

于 2012-06-25T20:34:28.843 回答