刷新或重新加载数据表 [英] refresh or reload datatable

查看:21
本文介绍了刷新或重新加载数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Jquery 数据表,其中包括对列的自定义呈现.根据值,我必须禁用其中的某些控件.我想在发布后重新加载/刷新/重新绑定我的 jquery 数据表.我该怎么做?

I'm using Jquery Datatable which includes customized rendering for columns. Based on values, I've to disable certain control in it. I want to reload/refresh/rebind my jquery datatable after post. How can I do that?

**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>

更新:**

Update:**

我找到了答案:

  • 清除表格 ( fnClearTable )

  • clear the table ( fnClearTable )

向表中添加新数据 (fnAddData)

add new data to the table ( fnAddData)

重绘表格 ( fnDraw )

redraw the table ( fnDraw )

推荐答案

我找到了答案:

clear the table ( fnClearTable )

add new data to the table ( fnAddData)

redraw the table ( fnDraw )

这篇关于刷新或重新加载数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆