none
REST API - Listing with Pagination Issues RRS feed

  • Question

  • 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>


    • Edited by M.Hijazi Thursday, August 3, 2017 7:31 AM
    Thursday, August 3, 2017 4:43 AM

Answers

  • Thanks for reply.

    But the scripts are the same, and that's my issue.

    Skip & skiptoken are not working properly ☺

    • Marked as answer by M.Hijazi Sunday, August 6, 2017 9:48 AM
    Friday, August 4, 2017 5:35 PM

All replies