How to destroy a datatable?

后端 未结 8 1660
萌比男神i
萌比男神i 2021-02-01 05:19

I\'m using datatables and using bootstrap-daterangepicker to select a range for which data will be shown in Datatables.

It is working fine.

The problem is when I

8条回答
  •  长情又很酷
    2021-02-01 05:52

    For the google searchers

    Very hardly I managed to destroy the Datatable, Empty it's all previous data before loading new data and re-initializing Datatable by doing like this,

    if ($.fn.DataTable.isDataTable("#myTbl")) {
          ("#myTbl").DataTable().destroy();
    }
    $('#myTbl tbody > tr').remove();
    
    ...
    
    // Load table with new data and re-initialize Datatable
    

提交回复
热议问题