The important parts to note in this code are the RowLimit element in the CAML query and the SP.ListItemCollection.get_listItemCollectionPosition(); property. Please have a look at the comments to know more details about the individual lines of code.
The ListItemCollectionPosition.pagingInfo determines the id of the last item fetched along with the filter and sorting criteria. It specifies information, as name-value pairs, required to get the next page of data for a list view.
This is fine to navigate to next page. I can use the id of the last item queried. But when we want to go to previous page, what can be the solution.. we cannot the use this method, to navigate both sides.. it is helpful only for navigating to next page..
To go to the previous page, you will have to keep track of the listitemcollectionposition of the previous page in a variable. And when you want to go to the specific position, use the value from the variable.
Alternatively, you can cache the current list items when you go to the next page. And when you want to go back from the next page, show the cached items
Post a Comment