Topic: Datatable jump to specific page on load
I would like to jump to a specific page when the DataTable is loaded, specifically the last page as after adding a new row to the bottom of the table list, I would like to navigate to that page to show the user that the newly added record is available in the list.
How do I achieve this?
The easiest way is to trigger click event just after initialization or data update. Here's the example code:
$('#dtBasicExample').DataTable(); $('.dataTables_length').addClass('bs-select'); let pageItems = $('#dtBasicExample_wrapper').find('.page-item'); pageItems.last().prev().click();
Thanks Mikołaj. This works perfectly fine.
On a side note, how do I remove sorting on specific columns? Right now the DataTable has sorting on all columns and I can't seem to figure out how to remove from specific ones on which I do not want any sorting.
Hi there again,
For this moment sorting works in the simplified way. You can only turn it on or off for the whole table.
Too bad. Anyway, thanks for the reply Mikołaj.
- User: Pro
- Premium support: Yes
- Technology: jQuery
- MDB Version: 4.6.0
- Device: Desktop
- Browser: Chrome 71.0.3578.98 (64-bit)
- OS: Windows 8.1
- Provided sample code: No
- Provided link: No