Is there a way to implement an external button that is similar to pagination in datatables?
Is there a way to implement an external button that is similar to pagination in datatables?
I have two views on a page.
On the left is the datatable and on the right side is the detail view.
The detail view has a previous and next buttons and the details of the row.
I would like to traverse the whole collection of models using these external buttons.
However since I am using server side processing in my data tables, I can't pass one collection at one point.
In summary, I would like to have two external buttons(previous, next) to be able to traverse the whole collection while also making the two views in sync.
So for example on initialize the datatable has 10 rows, after traversing through 10 rows the next button will trigger the datatable to go to the next page and display the next 10 rows.
Any suggestions on how I can do this?
This question has an accepted answers - jump to answer
Answers
Use the
page()
. There is an example at the bottom of the docs page that is doing what you are asking for.Kevin
Hi @kthorngren , Thanks it worked. Only problem left is I want to disable/enable the previous and next buttons depending if there is a previous/next page left.
How can I check that the current page is the last one?
So for example if the datatable only has 10 pages of data, if I reach the last page I want to disable the next button.
You can use
page.info()
to the total number of pages in the table.Kevin
Thanks that worked perfectly! Thank you for your time