- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 07:38 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 12:02 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2019 02:56 AM
Hi Larstange,
Thanks for sharing the steps.
Just wanted to check if you or anyone tried to implement it on Tabbed widgets.
I tried to do so but the pages gets in sync between the tabs. For example, if one tab has 50 records and other has 33 records and the Items per page is 10. There will be 5 pages displayed for both the tabs , consequently there will be one extra page in the first tab which will have no data.
This could be because of the same directive being used. I tried to replicate and still the same result.
Any information on the above scenario is highly appreciated. Much thanks in advance
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2025 01:00 PM
Did you ever figure this out?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2024 08:38 PM
Hello, can this work on two widgets on the same page? I also used this on my widget and it works great on one, but if I add another widget on the same page using this directive, it does not work independently. Like if I click next page on the first widget, it also updates the second widget to the next page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2024 08:03 PM
Hello Iarstange,
I too have same requirement but i try same steps as mentioned but its not working for me.
I have verified everything but getting this.
Can you please suggest me is there any change in new version, or do i need to add any code in server side or client side.
Regards
Pramod Pandey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2017 11:07 AM
Hi Malu, were you able to achieve? could you share the details here?