How do I clear and reload the the data in dataTable()?
How do I clear and reload the the data in dataTable()?
**1 On load i am loading the data in the data Table, **
$(document).ready(function () {
$('#example').DataTable({
data: currentSelectedPolicyResults.data,
scrollY: '50vh',
columns: [
{ title: "TaskId", data: "TaskId" },
{ title: "Task Description", data: "Task Description" },
{ title: "Status.", data: "Status" }
]
});
setClick();
});
2: How do i clear the data from current table?
3. Then I want to load updated JSON into the same table, How do i do this?
Answers
Have you looked at the ajax examples?
i did, I can clear the data using
var table = $('#example').DataTable();
table.clear().draw();
But when i try to load updated JSON its showing this error "DataTables warning: table id=example - Cannot reinitialise DataTable."
Reload Function : table.rows.add(UpdatedJSON.data);
Did you follow the troubleshooting steps linked to in the error?
https://datatables.net/manual/tech-notes/3
That should point you to the solution.
Kevin