Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

REST API - Listing with Pagination Issues

$
0
0

Hello everyone,

Below is my code I have just changed it to return json format results, I'm getting wrong results ONLY IF I have deleted one or more item, since this query it is fully based on item id. otherwise it runs fine.

Any ideas, I knew that skiptoken is better than skip... but both look having issues?? or can I use d.__next instead somewhere here without changing the whole method??

<script>
  angular.module('test-paging', ['ngSanitize'])
  .controller('ListController', function($scope, $q, $http) {
    var listUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('Announce')/";
    var itemLimit = 10;
    $scope.load = function(page) {
      $scope.activePage = page;
      $q.all({
        items: $http.get(listUrl + "Items", {
          params: {
            $select: "Title,Body",
            $top: itemLimit,
            $skiptoken: "Paged=TRUE&p_ID=" + ((page - 1) * itemLimit)
          }
        }).then(function(res) {
          return res.data.value;
        }),
        itemCount: $http.get(listUrl + "ItemCount").then(function(res) {
          return res.data.value;
        })
      }).then(function(res) {
        $scope.items = res.items;
        var pageCount = Math.floor(res.itemCount / itemLimit) + 1;
        $scope.pages = _.range(1, pageCount + 1);
      });
    };
    $scope.load(1);
 });  </script>



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>