Reputation: 11
I have a server side datatable setup. I'm trying to set the datatable page, when hashchange event is triggered like this:
$(window).on('hashchange',function(){
$("#loans").dataTable().fnSettings().displayStart = 100;
console.log( 'Offset: ' + $("#loans").dataTable().fnSettings().displayStart );
$("#loans").dataTable().fnDraw();
});
The problem is that fnDraw()
reloads the whole table and ignores the displayStart argument. If I write fnDraw(false)
, it doesn't work ether. I need to dynamically set page number and then reload the table (and make it pass the new offset to ajax call URL), but instead it's requesting the offset at 0 not at 100. How can I accomplish this? Thanks!
Upvotes: 1
Views: 1827
Reputation: 58880
For DataTables 1.9 you can use fnPageChange()
API method to change page and redraw the table:
$('#loans').dataTable().fnPageChange(10);
For DataTables 1.10 you can use page()
API method to change page and redraw the table:
$('#loans').DataTable().page(10).draw('page');
Upvotes: 3