How to redraw DataTable with new data

前端 未结 7 449
感动是毒
感动是毒 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条回答
  •  Happy的楠姐
    2020-12-13 08:59

    You have to first clear the table and then add new data using row.add() function. At last step adjust also column size so that table renders correctly.

    $('#upload-new-data').on('click', function () {
       datatable.clear().draw();
       datatable.rows.add(NewlyCreatedData); // Add new data
       datatable.columns.adjust().draw(); // Redraw the DataTable
    });
    

    Also if you want to find a mapping between old and new datatable API functions bookmark this

提交回复
热议问题