Prefijo Sustantivo
Prefijo Sustantivo

Reputation: 525

datatables how to scroll to specific row without pagination

I have a datatable of about 90 rows long. The user performs some operation and the table must scroll to the corresponding row.

I know about the scroller plugin, but the user has demanded to have no pagination.

Upvotes: 3

Views: 4800

Answers (2)

Kotey
Kotey

Reputation: 113

My solution, where 'table' is datatable, and target row has 'shown' class:

var $row = $(".shown");
table.context[0].nScrollBody.scrollTo(0,($row[0].offsetTop));

Upvotes: 0

Gyrocode.com
Gyrocode.com

Reputation: 58880

You can use the code below to scroll page to particular row if you're not using scrolling:

var table = $('#example').DataTable({
   paging: false
});

var $row = $(table.row(30).node());   
$('html, body').animate({ scrollTop: $row.offset().top }, 2000);

See this example for code and demonstration.

Upvotes: 4

Related Questions