【发布时间】:2019-01-01 16:06:28
【问题描述】:
我在尝试使用增强型数据网格 (dojo v1.10) 执行服务器端分页时遇到问题。 第一页正确显示,但小部件(存储?网格?插件?)似乎忽略了“Content-Range”标题值作为响应,并且不允许获取下一页。 例如,响应标头包含“Content-Range: items 0-9/17”,分页显示“1 到 10 of 10 个项目”,下一页不可用。
经过一些调试后,我看到从 JsonRest 存储(查询函数)中正确读取了范围值
results.total = results.then(function(){
var range = results.ioArgs.xhr.getResponseHeader("Content-Range");
return range && (range = range.match(/\/(.*)/)) && +range[1];
});
...
但在 ObjectStore 的 fetch 方法中,totalCount 值未定义,然后使用 results.length:
var results = this.objectStore.query(query, args);
Deferred.when(results.total, function(totalCount){
Deferred.when(results, function(results){
if(args.onBegin){
args.onBegin.call(scope, totalCount || results.length, args);
...
有什么想法吗?
谢谢,
我的代码:
// get grid store
var restStore = new JsonRest(
{
target: "ks2/api/workflow/...",
});
var memoryStore = new Memory();
var store = Cache(restStore, memoryStore);
/*set up layout*/
var layout = [{
name: "id",
field: 'id',
width: '5%',
datatype:"string"
},
....
];
/*create a new grid*/
this.workflowGridWidget = new EnhancedGrid({
id: 'workflowGridWidget',
store: new ObjectStore({objectStore: store}),
structure: layout,
rowSelector: '20px',
plugins: {
pagination: {
pageSizes: ["10", "25", "50"],
defaultPageSize: 10,
description: true,
sizeSwitch: true,
pageStepper: true,
gotoButton: true,
maxPageStep: 4,//page step to be displayed
position: "bottom" //position of the pagination bar
}
}
});
/*append the new grid to the div*/
this.workflowGridWidget.placeAt("workflowDataGrid");
/*Call startup() to render the grid*/
this.workflowGridWidget.startup();
【问题讨论】:
-
尝试将defaultPageSize的值更改为更大的数字,您也应该尝试将其删除,对不起,我记不太清楚了,但几年前我遇到了一个与此相关的问题
-
感谢您的建议,但没有效果(defaultPageSize 已删除或价值较高)
-
您是否尝试过使用 Observable 存储而不是缓存和内存?类似于... Store =
Observable( new JsonRestStore({}));
标签: datagrid pagination dojo