Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add more options in records per page dropdown using datatable jquery

I've been using the datatable jquery (http://datatables.net/ ) plugin.

Everything is working fine, but now I want to be able to select more than the default options of records per page, by default I can choose 10 , 25 , 50 , 100. I want to add 15 and 30 to this list.

How can I do that, I searched on internet but could't find any answer.

Thanks

like image 415
General Electric Avatar asked Jan 22 '26 10:01

General Electric


1 Answers

Use pageLength and lengthMenu for setting the default view, like this:

$('#example').DataTable({
        "pageLength": 15,
        "lengthMenu": [[10, 15, 25, 35, 50, 100, -1], [10, 15, 25, 35, 50, 100, "All"]]
    });

old api

  $('#example').dataTable({
        "iDisplayLength": 15,
        "aLengthMenu": [[10, 15, 25, 35, 50, 100, -1], [10, 15, 25, 35, 50, 100, "All"]]
    });

Second array will hold the values for that will be displayed in the drop down menu

Read more: DataTables example - Page length options

like image 194
Daniel Avatar answered Jan 25 '26 08:01

Daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!