我正在使用 Jquery Datatable,其中包括列的自定义呈现。根据值,我必须禁用其中的某些控件。我想在发布后重新加载/刷新/重新绑定我的 jquery 数据表。我怎样才能做到这一点?
**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",
<!-- more config -->
function updateSuccess(data, status, xhr) {
//refresh datatable;
}
</script>
更新:* *
我找到了答案:
清除表( fnClearTable )
向表中添加新数据 (fnAddData)
重绘表格 ( fnDraw )