Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select second page as initial page with jQuery datatable

I am using jQuery datatable.By default it is showing first page as initial page .But i want to show the second page as default page.When i am using YUI data table .In that i have option like initialPage.Is there any possibility in jQuery datatable to select second page as initial page.

Thanks in advance...

like image 231
PSR Avatar asked Jun 12 '13 12:06

PSR


2 Answers

With version 1.10 of DataTables there is a displayStart option that will allow you to set the default page.

Note that the displayStart value is a zero based count of records, not pages. If you have 10 records per page, displayStart: 10 will show page 2

$('#my-datatable').DataTable( {
  'displayStart': 10
} );

https://datatables.net/reference/option/displayStart

like image 177
Th4t Guy Avatar answered Nov 15 '22 10:11

Th4t Guy


There isn't an option in default options object. However you can call fnPageChange function on datatable to set the pagenumber.

var table = $('#data_table').dataTable();
table.fnPageChange(2,true);

Where 2 is the page number and the second parameter asks datatable to redraw.

https://datatables.net/ref#fnPageChange

like image 21
kavin Avatar answered Nov 15 '22 10:11

kavin