Ramco Ramco

Ramco Ramco

  • 441
  • 3.4k
  • 522.8k

DataTable row not getting removed

Jun 2 2021 7:04 AM
Hi
 
   Record in Database is getting deleted but row is not getting removed from table
 $("#row_" + Id).remove(); is not working.
 
public JsonResult Delete(string ID)
{
dbLocation.Delete(ID);
return Json(new { success = true, message = "Saved Successfully" });
}
 

function Delete() {
var Id = $("#hiddenId").val().replace(/\r?\n|\r/g, "");
Id = Id.trim();
$.ajax({
url: "/Location/Delete",
data: { Id: Id },
type: "POST",
//contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (result) {
$("#row_" + Id).remove();
$('#DeleteModal').modal('hide');
clearTextBox();
$.notify(result.message, {
globalposition: "top center",
className: "success"
})
},
error: function (errormessage) {
alert(errormessage.responseText);
}
});
}
 
*********************************************
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.Id)
@Html.DisplayFor(modelItem => item.Description)
@Html.DisplayFor(modelItem => item.IsActive)
Edit
@{ if(item.IsActive == "N")
{
@:disabled="disabled"
}
}> Delete
}
*******************************
$(document).ready(function () {
$("#tblLocation").dataTable({
}); 
 
 
Thanks 

Answers (5)