How to destroy a datatable?

后端 未结 8 1869
萌比男神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 06:04

    From DataTable

    var table = $('#myTable').DataTable();
    $('#tableDestroy').on( 'click', function () {
    table.destroy();
    });
    

    Reload a full table description from the server, including columns:

    var table = $('#myTable').DataTable();
    $('#submit').on( 'click', function () {
        $.getJSON( 'newTable', null, function ( json ) {
            table.destroy();
            $('#myTable').empty(); // empty in case the columns change
    
            table = $('#myTable').DataTable( {
                columns: json.columns,
                data:    json.rows
            } );
        } );
    });
    

    Hope it will help

提交回复
热议问题