DataTable : How to hide the pagination and only show it as need?

后端 未结 6 1447
耶瑟儿~
耶瑟儿~ 2021-02-13 01:51

I have 2 tables that are using DataTable jQuery Plug-in. I wondering if there is a way to hide my pagination on the bottom right of my table.

6条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-13 01:53

    You can use fnDrawCallback() method to hide the pagination in dataTable.

    var oTable = $('#datatable_sample').dataTable({
        "iDisplayLength": 10,    
        "fnDrawCallback": function(oSettings) {
            if ($('#datatable_sample tr').length < 10) {
                $('.dataTables_paginate').hide();
            }
        }
    });​
    

    The length which you can define as per the row you want to display in the listing.

提交回复
热议问题