Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Datatable jump to specific page on load

NitinMistry free asked 5 years ago


Hi,

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?


Mikołaj Smoleński staff answered 5 years ago


Hi there,

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();

Best regards


NitinMistry free answered 5 years ago


Too bad. Anyway, thanks for the reply Mikołaj.


Mikołaj Smoleński staff answered 5 years ago


Hi there again,

For this moment sorting works in the simplified way. You can only turn it on or off for the whole table.

Best regards


NitinMistry free answered 5 years ago


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.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB 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