datatable change show entries number | disable sort datatable

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’).

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

iDisplayLength is now legacy. Use pageLength instead.

How to disable sort in datatable?

Note that this will disable sorting all around, so there is no need to disable it on individual columns.

$('#jTable').dataTable({ "bSort" : false } );

Sorting apply per field, is:

$('#id-of-my-table').DataTable({
    "columnDefs": [
        { "orderable": false, "targets": [0, 4, 5, 6] },
        { "orderable": true, "targets": [1, 2, 3] }
    ]
});


Leave a Reply