JQuery DataTable deletes data and reloads it. jquerydatatable
Problem description:
A table composed of jQuery able and artTemplate. However, when deleting data, you need to reload the data in the table. However, the problem is that datatable does not directly re-render the data, but adds data fatigue.
Solution:
After checking the blog of Gao Ren, you can destroy the table and then re-render it.
var dttable;App.globalAjax("get", "/Order/MyJsonList", {}, function (result) { var html = template('Orders-template', result); $("#datatable1").find("tbody").html(html); dt = $('#datatable1').dataTable({ "sPaginationType": "bs_full" });});
This is the first time you get the data through ajax, then use artTemplate to render the data, and finally fill it in the page for rendering.
The next step is to delete the table and reload the rendered table.
App. globalAjax ("post", "/Order/DeleteOrder", data, function (result) {App. globalAjax ("get", "/Order/MyJsonList", {}, function (result) {var html = template ('Orders-template', result ); if ($ ('# datatable1 '). hasClass ('able able') {dttable = $ ('# datatable1 '). dataTable (); dttable. fnClearTable (); // clear table dttable. fnDestroy (); // restore the initialized able} $ ("# datatable1 "). find ("tbody" ).html (html); $ ('# datatable1 '). dataTable ();});});
At this point, the datatable can be re-rendered.