AngularJs Smart Table Pagination - Always Resets to First Page
Asked Answered
P

0

7

For some reason, my pagination is always resetting to 1 as the selected page, even though the result comes back from the server with the proper data in the results EG Records 31 - 45) and populate properly in the smart table. What could cause it to always reset the selected page in the pagination view to page 1? Is there a way to say what the selected page is?

Thanks in advance

Controller Method

 $scope.getData = function (tableState) {
        var pagination = tableState.pagination;
        var start = pagination.start || 0;
        var number = pagination.number || 10;

        $scope.users = UserServicePaging.query({offset: start});
        $scope.users.$promise
            .then (function (result) { //success
                $scope.users = result[0].results;
                $scope.rowCollection = $scope.users;
                $scope.displayedCollection =  [].concat($scope.rowCollection);  
                tableState.pagination.numberOfPages = Math.ceil(parseInt(result[0].records.total)) / 15;
                tableState.pagination.totalItemCount = Math.ceil(parseInt(result[0].records.total));
            },
            function (error) {//fail

            })
            .finally(function() {

            });
    }

Table Header:

 <table st-table="displayedCollection" st-safe-src="rowCollection" st-pipe="getData"  class="table table-striped">

Table Footer

<td colspan="5" class="text-center">
     <div st-pagination="" st-items-by-page="itemsByPage" st-displayed-pages="10"></div>
</td>
Purulent answered 13/10, 2015 at 23:40 Comment(2)
You don't have to use st-safe-src when using st-pipeBergeron
Yup that was the problem. ThanksPurulent

© 2022 - 2024 — McMap. All rights reserved.