Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass a total into the pagination? #146

Closed
dmackerman opened this issue Aug 22, 2014 · 2 comments
Closed

Pass a total into the pagination? #146

dmackerman opened this issue Aug 22, 2014 · 2 comments

Comments

@dmackerman
Copy link

Is there a way to pass a "total" number of records into the pagination? I only want to fetch say the first 20 records from my server, and then pass limit and skip options with each click on the pagination buttons using the st-pipe plugin, but I can't figure out how to get all of the page numbers to display by default - based on a total property I get back from my server.

Am I thinking about this wrong perhaps?

@lorenzofox3
Copy link
Owner

Hello, from within the table, you can get access to the table state with the controller method tableState() and then assign numberOfPages to your total number of page
Or better in your case, do it from your custom pipe function

$scope.customPipe=function pipe(tableState){
     //note 'this' in this function is actually bound to the table controller

    var serverquery=transformToQuery(tableState);
    httpService.query(serverquery).then(function(response){
        //assign data
         $scope.rowCollection=response.data;

        //change table state from what tells the server
       tableState.pagination.numberOfPages=response.totalNumberOfPages;   
    });
}

Laurent

@dmackerman
Copy link
Author

Ah, makes total sense. Will give that a shot! 👍

One thing though, it's seems that tableState in my pipe function only gets triggered on change, not on initial load. Is that expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants