Set the number of pages for pagination manually?
Set the number of pages for pagination manually?
caleb
Posts: 2Questions: 1Answers: 0
I am calling data from an API and displaying it on the table.
I was wondering if there was a property to make it that the pagination is not based on how many records are returned, but done manually because I am using my own methods to display number of records on the table and getting the current and total number of pages from the API.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Does the
page.len()
API fit your needs?Kevin
page.len() sets the number of records showing which is what I use for that, but I am talking about at the bottom of the table where it as previous 1 .... 6 next.
I want to set the max number of pages to a value.
Do you mean that you want to tell DataTables that there will be a maximum of 10 pages (for example), regardless of the number of records that exist in the table? It would then therefore adjust the page size automatically?
There isn't a built in option for that, but if you use
page.info()
to get the number of records, you could use thepage.len()
method that Kevin mentioned to calculate and then set the required page length.Allan