javascriptsharepointpaginationclient-sidelistitem

SharePoint2013 - Javascript - Pagination in client side- Using listitemcollectionposition


I am getting data from a sharepoint list based on certain filter criteria.

I am getting the records using javascript object model. This is working fine.

I am facing issue with pagination.

I have referred this article :

http://social.technet.microsoft.com/wiki/contents/articles/18606.sharepoint-2013-paging-with-sharepoint-client-object-model.aspx

This works for "Next Page". Doesnt work for "Previous Page" in my case, because the values are retrieved randomly. So,the IDs are not consecutive.

Does "listItemCollectionPosition" work only for data which is consecutive?

previousPagingInfo = "PagedPrev=TRUE&Paged=TRUE&p_ID=" + myListItems.itemAt(0).get_item('ID');

This code doesnt work properly, some records are getting missed out.


Solution

  • You can find a good example here, how to page in CSOM: https://code.msdn.microsoft.com/office/SharePoint-JSOM-list-5104ca92

    There are some articles that gives you the following answers about paging in Sharepoint 2013.

    A very important consideration to take into account: - with JSOM or the classic webservices svc/asmx or oData, you cannot use the "$skip" particle to do paging of listitems. So it is OOTB almost impossible to do a true paging with numbers. For items, you have to use listItemCollectionPosition in your SOAP or using $skiptoken (oData). The only paging possible is previous/next.