我正在尝试将 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);
最佳答案
您指定使用哪个缓存了吗?在您的情况下,它应该是异步缓存。
require([
'gridx/core/model/cache/Async',
.....
], function(Cache, ...){
this.grid = new Grid({
cacheClass: Cache,
......
});
关于Dojo Gridx 与 JsonStore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10582455/