Change values of select box of “show 10 entries” of jquery datatable

后端 未结 9 1398
攒了一身酷
攒了一身酷 2021-01-30 12:24

By default, jquery datatable shows 10 by default and has

options : 10,25,50,100

How can I change these options?

相关标签:
9条回答
  • 2021-01-30 13:19
    $(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

    0 讨论(0)
  • 2021-01-30 13:22

    pageLength: 50,

    worked for me Thanks

    Versions for reference

    jquery-3.3.1.js

    /1.10.19/js/jquery.dataTables.min.js

    /buttons/1.5.2/js/dataTables.buttons.min.js

    0 讨论(0)
  • 2021-01-30 13:23

    if you click some button,then change the datatables the displaylenght,you can try this :

     $('.something').click( function () {
    var oSettings = oTable.fnSettings();
    oSettings._iDisplayLength = 50;
    oTable.fnDraw();
    });
    
    oTable = $('#example').dataTable();
    
    0 讨论(0)
提交回复
热议问题