我正在使用Asp .net MVC3。我正在使用html表在前端显示表。我正在使用datatable插件进行分页,排序和过滤。当用户在第1页上选择2条记录时导航到下一页确认框必须显示为“您要提交所选值吗?”如果用户点击确定必须完成导航,否则它应该保留在第1页上。以下是我的表,
<table id="myIndiaTable">
<thead>
<th>Select All<input type="checkbox" class="chkheadind" onchange="Getchecked()" /></th>
@foreach (var item in Model.colName)
{
<th>@item.column_name</th>
}
</thead>
<tbody>
@foreach (var item in Model.bgv)
{
<tr>
<td><input type="checkbox" class="chkdataind"/></td>
<td id ="AsscId">@item.AsscID</td>
<td id ="AsscName">@item.AsscName</td>
<td>@Html.DropDownList("Education", new SelectList(Model.dd, "Validation_Code", "Validation_Status", @item.Education),new { style = "width: 80px;" })</td>
<td>@Html.DropDownList("Employment", new SelectList(Model.dd, "Validation_Code", "Validation_Status", @item.Employment),new { style = "width: 100px;" })</td>
<td>@Html.DropDownList("Criminal", new SelectList(Model.dd, "Validation_Code", "Validation_Status", @item.Criminal),new { style = "width: 80px;" })</td>
<td>@Html.DropDownList("DatabaseTest", new SelectList(Model.dd, "Validation_Code", "Validation_Status", @item.DatabaseTest),new { style = "width: 100px;" })</td>
</tr>
}
</tbody>
</table>
以下是jquery,
<script type="text/javascript">
$("#myIndiaTable").dataTable({
"bFilter":true,
"bSort": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 5,
"aLengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
"bStateSave": true,
"bProcessing": true,
"bDeferRender":true
});
</script>
答案 0 :(得分:0)
我用过
"fnDrawCallback": function (oSettings) {
}
每当再次绘制表时重新初始化某些内容(不仅仅是在分页情况下)。这可能不适合你的情况。
对于分页,文档建议使用
"fnUpdate": function ( oSettings, fnCallbackDraw )
{
// check what you want
// return true or false. true is expected to paginate and false is expected not to paginate
}