Cannot reinitialise JQuery DataTable

前端 未结 9 627
北恋
北恋 2020-12-13 19:32

I\'m using jquery datatables to display data inside grid. On init page load script take DateTime.Today and process them further, problem is after init page load, when I\'m t

9条回答
  •  春和景丽
    2020-12-13 19:48

    The DataTables API has changed, but this error is still thrown if you try to reinitialize the datatable again.

    You can check if it is already created with:

    $.fn.DataTable.isDataTable("#myTable")
    

    And to destroy it so that it can be recreated again:

    $('#myTable').DataTable().clear().destroy();
    

    It is not the most efficient way, but it works. It should be possible to update the table without destroying it first, just using clear and row.add, but I haven't found a way of doing that when the data source is an array passed to the constructor.

提交回复
热议问题