How to change results per page value in datatables

前端 未结 7 1064
日久生厌
日久生厌 2021-01-30 21:35

Datatables has an option to select the number of records shown per page. The default value starts from 10, 25, 50 and 100. How can I change it to start from 5 instead of 10? 10

7条回答
  •  一个人的身影
    2021-01-30 21:56

    You can simply add:

    "lengthMenu": [ 
     [10, 25, 50, -1], 
     [10, 25, 50, "All"] 
    ] // remember to add  "," if you initialize more option manually
    

    or if you only want to add this option

    $('#tablename').dataTable( {
      "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ]
    } );
    

    which will give you a drop-down to select the number of records per page in pagination.

提交回复
热议问题