dojo enhanced grid server side pagination not working

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


dojo enhanced grid server side pagination not working



I'm facing an issue when trying to perform server side pagination using an enhanced datagrid (dojo v1.10).
The first page is correctly displayed, but the widget (store ? grid ? plugin ?) seems to ignore the 'Content-Range' header value in response and does not allow to get next page.
For example with response header containing 'Content-Range: items 0-9/17', pagination displays '1 to 10 of 10 items', and next page is not available.



After some debug I see that range value is correctly read from JsonRest store (query function)


results.total = results.then(function(){
var range = results.ioArgs.xhr.getResponseHeader("Content-Range");
return range && (range = range.match(//(.*)/)) && +range[1];
});
...



But in fetch method from ObjectStore, totalCount value is undefined, results.length is then used:


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);
...



Any idea ?



Thanks,



My code:


// 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();





Try to change the value of defaultPageSize to a bigger number, also you should try to remove it at all, sorry but I dont remember it so well but I had an issue related to that some years ago
– undefinedBehavior
2 days ago





Thanks for suggestion, but no effect (defaultPageSize removed or with high value)
– Vincent-ks2
2 days ago





Have you tried using an Observable store instead of Cache and Memory? Something like... Store = Observable( new JsonRestStore({}));
– Layke
yesterday


Observable( new JsonRestStore({}));




1 Answer
1



I found the issue: I was using a non dojo restful compliant API, and I needed to add JSON response post-processing using


aspect.after(store, "query", this.processResponse);
...

processResponse: function ks2ProcessMonitor_datagrid_WorkflowDataGrid_processResponse(deferred) {
return deferred.then(function(response) {
//process response content
return processedResponse;
});
},



This was working properly but for some reason, it has an impact on pagination. Removing this post-processing (using another API which is dojo compliant) fix the pagination issue.
Maybe I should try response post-processing using an Observable as suggested by Layke.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to scale/resize CVPixelBufferRef in objective C, iOS

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

SVG with two text elements. When one resizes due to textLength - how to resize the other one to the same character size