AnsweredAssumed Answered

Alfresco.util.DataTable and search maxItems

Question asked by loftux Moderator on Feb 3, 2011
Latest reply on Feb 3, 2011 by erikwinlof
Hi,

I'm using the Alfresco.util.DataTable and trying to get paging to work.
In the DataTable widget, maxItems is the max number of rows per page, in Alfresco javascript search object it is the maxItems to return in a search:
  var paging =
  {
     maxItems: 10,
     skipCount: 0
  };
That is, on the server side if I set the maxItems, the search will stop when maxItems is reached. But returning this to the DataTable, the DataTable has no way of knowing that there actually is a larger set available, and there is no paginater pages created.
So if I only use maxItems for the DataTable, and set
  var paging =
  {
     maxItems: 100, //Can possibly skip entirely
     skipCount: 10 //from passed in DataTable, page 2 of max 10 per row
  };
in this case, I also return the max number of hits to the DataTable. Paginator is created.
But if there is a total of 100 hits, I get 90 items returned.

What I'm missing is a maxRowItems in the javascript search API.
I guess I can emulate that in javascript by just returning the first 10 (it that is what I want per row).

on further testing I resolved paging:
In you webscript, always return searchresults.length+scipcount to get actual number of hits, since search subtracts the scipcount from total hits (correctly so)
This would be part of your json return
"paging": 
   {
      "totalItems": ( searchresults.length+scipcount),
      "maxItems": 10,
      "skipCount": (the current value of skipped items)
   }
Also, loop the searchresults and only return the first maxItems, so that you do not return an an unnecessary large result set.

Outcomes