Reputation: 525
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
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
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