Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change values of select box of "show 10 entries" of jquery datatable

By default, jquery datatable shows 10 by default and has

options : 10,25,50,100

How can I change these options?

like image 557
rjmcb Avatar asked May 17 '12 06:05

rjmcb


People also ask

How do I change the length of a data table?

Use page. len() API function to change page length dynamically. This method changes the number of rows shown, but the number in the Show x Entries select box remains the same.


2 Answers

Don't forget to change the iDisplayLength as well:

$(document).ready(function() {     $('#tbl_id').dataTable({         "aLengthMenu": [[25, 50, 75, -1], [25, 50, 75, "All"]],         "iDisplayLength": 25     }); } ); 
like image 143
davesave Avatar answered Sep 20 '22 07:09

davesave


$(document).ready(function() {     $('#example').dataTable( {     "aLengthMenu": [[25, 50, 75, -1], [25, 50, 75, "All"]],     "pageLength": 25     } ); } ); 

aLengthMenu : This parameter allows you to readily specify the entries in the length drop down menu that DataTables shows when pagination is enabled. It can be either a 1D array of options which will be used for both the displayed option and the value, or a 2D array which will use the array in the first position as the value, and the array in the second position as the displayed options (useful for language strings such as 'All').

Update

Since DataTables v1.10, the options you are looking for are pageLength and lengthMenu

like image 29
Priyank Patel Avatar answered Sep 19 '22 07:09

Priyank Patel