How to dynamically change jQuery Datatables height

前端 未结 8 1905
情话喂你
情话喂你 2021-01-31 05:25

I\'m using jQuery Datatables. I want to change the height of the table whenever a user resizes the window. I\'m able to catch the window resize event which allows me to calculat

8条回答
  •  花落未央
    2021-01-31 05:43

    For DataTables 1.10:

                $("#table").DataTable( {
                  scrollY: '250px',
                  scrollCollapse: true,
                  paging: false,
                });
    
                $('#table').closest('.dataTables_scrollBody').css('max-height', '500px');
                $('#table').DataTable().draw();
    

    When you changed CSS you must call draw().

提交回复
热议问题