Refresh DataTable after deleting data not working
Refresh DataTable after deleting data not working
feedz87@yahoo.com.my
Posts: 2Questions: 0Answers: 0
Hello,
I try for several hours to reload my dataTable, no success until now...
a.This is my code in js
function DeleteData(id) {
if(confirm('Are You Sure to Delete this Employee Record ?'))
{
$.ajax({
type: "POST",
url: '@Url.Action("Delete","Process")/' + id,
success: function (data) {
if (data.success)
{
DataTable.ajax.reload();
}
}
});
}
}
b. This is my code in .net core controller
[HttpPost]
public ActionResult Delete(int id)
{
var process = _db.ProcessTbl.Where(e => e.ProcessID == id).FirstOrDefault();
_db.Remove(process);
_db.SaveChanges();
return Json(new { success = true, data = process });
}
Errors - No error shown but the datatable row not refresh after deleting data
I tried a lot of possibilities, no success.
Thank you in advance for your help.
Replies
Is the
if (data.success)
on line 8 working as you expect? Meaning is it reaching theDataTable.ajax.reload();
statement?Have you used the browser's network inspector to verify the
data.success
value in the response?Can you post a link to your page or a test case showing the issue so we cn help debug?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Hi Kevin,
if (data.success) is working properly and can reach the DataTable.ajax.reload();
data.success value response = true
network inspector result as follow :
It would be worth looking at Editor since the API is designed to simplify this kind of operation.
Colin