Set the number of pages for pagination manually?

Set the number of pages for pagination manually?

calebcaleb 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

Answers

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945

    Does the page.len() API fit your needs?

    Kevin

  • calebcaleb Posts: 2Questions: 1Answers: 0

    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.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    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 the page.len() method that Kevin mentioned to calculate and then set the required page length.

    Allan

This discussion has been closed.