分页丢失了数据表值 [英] Paging loses datatable values
本文介绍了分页丢失了数据表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
[ ^ ]
<table ID="tblUploadExcel">
@{int i = 0;}
@foreach (var p in Model)
{
<tr>
<td><label id="WorkItemId_@i">@p.WorkItemId</label></td>
<td>
@Html.TextBox("EstimatedDateTime", null, new { @id = "EstimatedDateTime_" + i })
</td>
<td>@Html.DropDownList("AssignedTo_" + i, (IEnumerable<SelectListItem>)@p.Uinfo, "--Select Name--")</td>
</tr>
i++;
}
</table>
<script>
function Save() {
var rowCount = $('#tblUploadExcel').dataTable().fnGetData().length;
//write jquery logic to read table data and push into list and then send to controller action,
//read data in controller action for storing into db
var workList = [];
for (var i = 0; i <= rowCount - 1; i++) {
var WorkItemDetails = {};
WorkItemDetails["WorkItemId"] = $("#WorkItemId_" + i).text();
WorkItemDetails["EstimatedDateTime"] = $("#EstimatedDateTime_" + i).val();
WorkItemDetails["AssignedTo"] = ($("#AssignedTo_" + i).val());
workList.push(WorkItemDetails);
}
var workinfo = JSON.stringify(workList);
var info = { "prodsjson": workinfo };
//send ajax request
$.ajax({
type: "POST",
// traditional: true,
//async: false,
cache: false,
url: '/Admin/WorkDetais',
//context: document.body,
data: info,
success: function (result) {
},
error: function (xhr) {
//debugger;
console.log(xhr.responseText);
alert("Error has occurred..");
}<
});
}
</script>
I am using "Bootstrap-Table-With-Sorting-Searching-and-Paging" using
<a href="http://www.codeproject.com/Tips/823490/Bootstrap-Table-With-Sorting-Searching-and-Paging">This artical</a>
Issue:- I have 20 recodes in my dataTable and trying to Save.But inputs and labels losing-values-when-paging
Any Idea to make it work
我尝试了什么:
我试图删除Bootstrap。然后它工作正常,但我需要引导程序并保存所有值与单一提交
What I have tried:
I was Trying to remove Bootstrap. then its working fine but i need both bootstrap and save all values with single submit
推荐答案
(' < span class =code-string>#tblUploadExcel')。dataTable()。fnGetData()。length;
// 编写jquery逻辑来读取表数据并推送到列表中然后发送到控制器操作,
// 读取控制器操作中的数据以存储到db
var workList = [];
for ( var i = 0 ; i< = rowCount - 1 ; i ++){
var WorkItemDetails = { };
WorkItemDetails [ WorkItemId] =
('#tblUploadExcel').dataTable().fnGetData().length; //write jquery logic to read table data and push into list and then send to controller action, //read data in controller action for storing into db var workList = []; for (var i = 0; i <= rowCount - 1; i++) { var WorkItemDetails = {}; WorkItemDetails["WorkItemId"] =
( #WorkItemId _ + i).text();
WorkItemDetails [ EstimatedDateTime] =
("#WorkItemId_" + i).text(); WorkItemDetails["EstimatedDateTime"] =
( #EstimatedDateTime _ + i).val();
WorkItemDetails [ AssignedTo] =(
("#EstimatedDateTime_" + i).val(); WorkItemDetails["AssignedTo"] = (
这篇关于分页丢失了数据表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文