-
Notifications
You must be signed in to change notification settings - Fork 3
Paging
David Lidström edited this page Oct 27, 2017
·
3 revisions
Home » Paging
Paging with CAML queries is an interesting creature. It's a bit strange.
You can specify a row limit, but you can not specify which row index to start from. Normall you'd want to do like this:
Page 1: Get Row 0-10
Page 2: Get Row 11-20
...
But here you must use the ID of the items to do paging:
Page 1: Get first 10 rows (save: X = ID of the last item)
Page 2: Get first 10 rows (from id: X)
camlsql.prepare("SELECT * FROM [TheList] LIMIT 50")
.exec(function(err, rows, paging) {
// Here you can save the paging.nextPage info and use it in the next page's query:
nextPage = paging.nextPage
});
// Pass the saved value as pagingInfo parameter when invoking exec:
camlsql.prepare("SELECT * FROM [TheList] LIMIT 50")
.exec({
pagingInfo : nextPage
}, function(err, rows, pagingInfo) {
// Here you can save the pagingInfo.nextPage info and use it in the next page's query:
nextPage = pagingInfo.nextPage
});
Thanks to https://social.technet.microsoft.com/wiki/contents/articles/18606.sharepoint-2013-paging-with-sharepoint-client-object-model.aspx for clearing this up for me!