How to redraw DataTable with new data

前端 未结 7 456
感动是毒
感动是毒 2020-12-13 08:45

I have checked several questions already about this topic here in stackoverflow, but they are all using the old dataTable. I am using DataTable. I populated my DataTable by

7条回答
  •  鱼传尺愫
    2020-12-13 08:57

    If you want to refresh the table without adding new data then use this:

    First, create the API variable of your table like this:

    var myTableApi = $('#mytable').DataTable(); // D must be Capital in this.
    

    And then use refresh code wherever you want:

    myTableApi.search(jQuery('input[type="search"]').val()).draw() ;
    

    It will search data table with current search value (even if it's blank) and refresh data,, this work even if Datatable has server-side processing enabled.

提交回复
热议问题