Pagination in service portal

malu
Tera Contributor

I have a pagination to setup for a widget. My widget displays information from a custom table. Customer like to have a pagination to setup for the list of records produced in the widgets BUT unable to run a filter on the client script.

my code below

HTML

<tr ng-repeat="item in c.data.usersList | startFrom: currentPage*pageSize | limitTo: pageSize">

<button ng-disabled="currentPage == 0" ng-click="currentPage=currentPage-1">

              Previous

  </button>

      {{currentPage+1}}/{{numberOfPages()}}

<button ng-disabled="currentPage >= c.data.usersList.length/pageSize - 1" ng-click="currentPage=currentPage+1">

              Next

  </button>

Client script:

function($scope){

$scope.currentPage = 0;

  $scope.pageSize = 12;

     

      $scope.numberOfPages=function(){

              return Math.ceil($scope.c.data.usersList.length/$scope.pageSize);                              

      }

$scope.filter('startFrom', function() {

      return function(input, start) {

              start = +start; //parse to int

              return input.slice(start);

}

      });

}

I can get the Previous button and Nextbutton with the total number of pages but unable to see the data for it.

$scope.filter is responsible to produce the output BUT somehow is the failing.

Pls help

1 ACCEPTED SOLUTION

larstange
Mega Sage

Hi



For pagination I would recommend using "Pagination Directive": angularUtils/src/directives/pagination at master · michaelbromley/angularUtils · GitHub



I have used that in a variety of widgets and its is really a plug'n'play solution where you don't have to build all the logic your self.


View solution in original post

15 REPLIES 15

 Hi Karthik please find the detailed explanation in this thread

 

Click Here

 

Hope this will be helpful for others also