Set number of pages programmatically
Set number of pages programmatically
Is it possible to set the number of pages programmatically?
This is because I receive from the server just one page of records, but I want to set the real number of records (and so the real number of pages), so that the user can see the bottom pagination buttons. Using classic service side processing with Ajax request is quite problematic and not viable, and using something $('#example').DataTable().page.info().pages = numberOfPages or $('#example').DataTable().page.info().recordsTotal = numberOfRecords does not work.
This question has an accepted answers - jump to answer
Answers
Hi @light2288 ,
No, that's not possible I'm afraid. But if you use
serverSide
, only one page of data is returned at a time, so I suspect that may resolve your issue.Cheers,
Colin
Thanks to @colin answer, this is how i solved, I leave it here for future reference.
1) I receive a JSON with this structure:
2) Create a JSON structure from the one I receive from server this way:
This seems to work also without recordsTotal but I left it just to be sure
3) When initializing the table, set this properties:
I don't know if it is the best way to solve it but in my specific case it works well.