缓存在jQuery数据表MVC中填充了错误的复选框

缓存在jQuery数据表MVC中填充了错误的复选框,jquery,asp.net-mvc,datatables,browser-cache,Jquery,Asp.net Mvc,Datatables,Browser Cache,我的mvc视图有一个使用.datatable的表。每行有许多列,名称。。。和一个复选框。如果我按原始名称以外的其他列对表进行排序,然后导航到别处,然后按“上一步”,则缓存会使用名称排序将viewmodel数据加载到表中,但随后缓存似乎会根据先前选中的使用不同排序的行选中复选框 前 (原件) 按编号排序(.datatable) 转到新页面,然后返回 我在javascript上等待了一段时间。准备好了吗?这样我就可以看到未设置样式的表了 name | number |checked A |

我的mvc视图有一个使用.datatable的表。每行有许多列,名称。。。和一个复选框。如果我按原始名称以外的其他列对表进行排序,然后导航到别处,然后按“上一步”,则缓存会使用名称排序将viewmodel数据加载到表中,但随后缓存似乎会根据先前选中的使用不同排序的行选中复选框

(原件)

按编号排序(.datatable)

转到新页面,然后返回

我在javascript上等待了一段时间。准备好了吗?这样我就可以看到未设置样式的表了

name | number |checked
A    |   3    |   X
B    |   1    |   
C    |   2    |
然后,一旦datatable运行

name | number |checked
B    |   1    |   
C    |   2    |
A    |   3    |  X
我在chrome和IE中进行了测试,问题只出现在chrome中

<table class="table table-striped table-bordered" style="text-  transform:none!important">
        <thead>
            <tr>
                <th>Name
                </th>
                <th>Number
                </th>
                <th>Checked
                </th>
</tr>
        </thead>
        <tbody>

            @if (@Model.records.Count() > 0)
            {
                foreach (var item in @Model.records)
                {
                <tr>
                    <td>@item.Name</td>
                    <td>@item.number</td>
                    <td>@Html.CheckBox("chkhide", @item.IsHidden, new { @class = "hide_check", id = item.Id })</td>

 </tr>
                }
            }

        </tbody>
    </table>

<script type="text/javascript">
jQuery(document).ready(function () {

    $('.table').dataTable(
      {
          "sDom": 'T<"clear">lfrtip',
          "oTableTools": {
              "sSwfPath": "../../../../Content/DataTables-1.9.4/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
              "aButtons": ["copy", "csv"]
          },
          "bPaginate": false,
          "bSortCellsTop": true,
          "bSortClasses": false,
          "bStateSave": true
      });

名称
数
选中的
@如果(@Model.records.Count()>0)
{
foreach(@Model.records中的var项)
{
@项目名称
@项目编号
@复选框(“chkhide”,@item.ishiden,new{@class=“hide_check”,id=item.id})
}
}
jQuery(文档).ready(函数(){
$('.table').dataTable(
{
“sDom”:“Tlfrtip”,
“可旋转工具”:{
“sSwfPath”:“../../../../../Content/DataTables-1.9.4/extras/TableTools/media/swf/copy\u csv\u xls\u pdf.swf”,
“阿布顿”:[“复制”、“csv”]
},
“bPaginate”:错误,
“bSortCellsTop”:正确,
“bSortClasses”:false,
“bStateSave”:true
});

通过强制服务器端刷新模型数据解决了这一问题。看起来这只是与chrome缓存系统的datatables接口的一个bug。

需要一些代码或js提琴,否则我只是随口说说原因
name | number |checked
B    |   1    |   
C    |   2    |
A    |   3    |  X
<table class="table table-striped table-bordered" style="text-  transform:none!important">
        <thead>
            <tr>
                <th>Name
                </th>
                <th>Number
                </th>
                <th>Checked
                </th>
</tr>
        </thead>
        <tbody>

            @if (@Model.records.Count() > 0)
            {
                foreach (var item in @Model.records)
                {
                <tr>
                    <td>@item.Name</td>
                    <td>@item.number</td>
                    <td>@Html.CheckBox("chkhide", @item.IsHidden, new { @class = "hide_check", id = item.Id })</td>

 </tr>
                }
            }

        </tbody>
    </table>

<script type="text/javascript">
jQuery(document).ready(function () {

    $('.table').dataTable(
      {
          "sDom": 'T<"clear">lfrtip',
          "oTableTools": {
              "sSwfPath": "../../../../Content/DataTables-1.9.4/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
              "aButtons": ["copy", "csv"]
          },
          "bPaginate": false,
          "bSortCellsTop": true,
          "bSortClasses": false,
          "bStateSave": true
      });