4

I would like to implement paging in sharepoint 2013, so I would like to get current list item count first, then do the paging so I can tell users: 1-30 of 400 items, in my paging.

Can I do this in batching so i make a request first to get item count, then get top 30 items in my list in the same request?

1 Answer 1

3

To implemente pagination on this rest api is not that simple, you need to do some tweaks.

Default URL - "/sites/dev/_api/web/lists/getbytitle('StudentsList')/items?&$top=5";

For this go through the response of first REST Ajax call. If you read each property carefully you will get answer for pagination. Properly "__next" is nothing but the REST url for next page :). Is it simple? Yes. So use "data.d.__next" to get next page items. REST service always returns this property whenever there is possible next set of items otherwise returns null.

Below is what url you will get

enter image description here

To get total count you need to make /itemCount rest call.

Adjust your logic to divide data in pagination and use _next attribute to get next set of data.

Ref link

3
  • This doesn't answer my question. I know all of this. I am asking about a way to make the 2 calls in the same request. I know __next and itemCount. Is there a way to do both of them in the same request? thanks
    – Eddie
    Commented Dec 11, 2016 at 16:44
  • no...there is no way to do this in same request using rest api....also you should edit your question with what things you have tried..it helps others for answering.. Commented Dec 11, 2016 at 17:57
  • I didn't have to state what I tried as it's a different question i am saying i need to batch. i didn't expect an answer to a different question. thank you
    – Eddie
    Commented Dec 11, 2016 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.