• 2 replies
  • Latest Post - ‏2013-02-13T23:47:35Z by DGawron
20 Posts

Pinned topic Pagination and Sorting with Data Services

‏2013-02-12T09:17:34Z |
Hi All

We are using web services in the WEF 8. The pagination and sorting implemented at the services side.

The service will return total number of records available.

When user clicks on next page then I need to call service to get the data and display and same case with the Sorting.

Initially I thought the custom data retriever is solves this .... When I implemented I found the following behavior.

The custom data retriever will loop until no data required .....So it caches all the data locally. We do not want this behavior.

Only get the first 10 records and build the pagination depending on the total no of records returned by the initial service call.

When user clicks on pagination give the call service and get the current records.
Updated on 2013-02-13T23:47:35Z at 2013-02-13T23:47:35Z by DGawron
  • mburati
    2587 Posts

    Re: Pagination and Sorting with Data Services

    Dave's the expert on the paging infrastructure, but here's a stab at what's going on.

    In order to calculate the paging links to display and how to get to the last row if you click on last, it needs to know how many rows total there will be. With a DB based data retriever, it can ask the DB how many rows in the table, but for a custom data retriever like yours, it sounds like it's just walking the rows (via fetching pages of data) to figure out the count.

    There is also some related information on custom data retrievers and fetch size (and pre-fetching) in the following thread in this forum (found with the above search box, searching for custom data retriever):

    There's another paging row count related issue in the following thread, but this one does not sound like it's necessarily related (just good info to know):
    I hope that info helps,
    ..Mike Burati
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • DGawron
    580 Posts

    Re: Pagination and Sorting with Data Services

    There are usually 2 reasons why a custom retriever pulls in all the data. The first is that the paging code in WEF is looking for the last page and it keeps requesting pages until no more are available. To prevent this you need to either return -1 from the getRowCount() method or obtain, cache, and return the max row count you said is available from a response. -1 tells WEF the retriever doesn't know the total row count. Returning a cached row count is a bit more efficient overall.

    The other way retrievers are forced to bring back all the data is by a consumer or provider model that treats the retriever like a regular IXml variable by calling one of the IXml interface methods on the retriever. This forces the retrieve to behave like an IXml variable and pull in all the rows. This almost always indicates a bug in the model's design. A data retriever should rarely be treated like an IXml variable.