Razor Form没有将所有DataTables行发布到MVC Action?

问题描述 投票:0回答:1

我有一个DataTable,在View有100个可编辑的记录。我可以编辑记录并将它们发回MVC Action。如果我销毁DataTable并发布我的表格,我会在表格集合中获得所有100条记录。另一方面,如果我不破坏DataTable并点击提交,那么我只获得前10条记录。

这是我的代码:

@using (Html.BeginForm("Edit", "Events", FormMethod.Post))
{
  @Html.AntiForgeryToken()

  <button type="submit">  Save </button>

        <table id="tblEvents">
            <thead>
                <tr>
                   // Header
                </tr>
            </thead>
            <tbody>
                 // Records
            </tbody>
        </table>

}

脚本:

<script>

    $(document).ready(function () {

        var table = $('#tblEvents').DataTable();

        $("form").on('submit', function () {
            // If I remove this I get only first 10 Records.
            table.destroy();
        });
    });


</script>
asp.net-mvc post datatables
1个回答
0
投票

尝试使用ajax调用来提交表单,而不是重新加载整个页面,它可能会起作用

© www.soinside.com 2019 - 2024. All rights reserved.