I am using jQuery Datatable, which includes personalized rendering for columns. Based on the values, I have to disable certain controls in it. I want to reload / update / restore my jquery datatable after posting. How can i do this?
**Controller:** [HttpPost] public JsonResult PostAction(MyMOdel model) { //save changes to DB return Json(new { Success = result, }); } public ActionResult MyAction() //grab records from DB and return JSON } **View:** @using (Ajax.BeginForm("PostAction", "ControllerName", null, new AjaxOptions { UpdateTargetId = "update-message", InsertionMode = InsertionMode.Replace, HttpMethod = "POST", OnSuccess = "updateSuccess" }, new { @id = "myForm" } )) { <table id="myTbl" class="display"><tr><td>col1</td></tr></table> } <script type="text/javascript"> var oTable = $('#myTbl').dataTable({ "sAjaxSource": "/ControllerName/MyAction", function updateSuccess(data, status, xhr) { //refresh datatable; } </script>
Update: **
I found the answer:
clear table (fnClearTable)
add new data to the table (fnAddData)
redraw the table (fnDraw)
source share