如何解决在使用jquery将值设置为特定的td之后,如何从更新的表行中获取数据
成功提交表单后,我使用jQuery用新值更新了数据表行值。该部分如下所示。
//////////////Form Submision//////////////
$('#btnSaveCallRegisterTable').click(function () {
if (confirm('Do you want to ' + formAction + ' data ?','YES','No')) {
$.CCAjax("/Service/SaveServiceCall",form.serializeArray(),function (data) {
var jsonData = JSON.parse(data);
console.log(jsonData);
if (jsonData["Response_Code"] === 200 || jsonData["Response_Code"] === "200") {
$('#thisDivSuccessAlert').html('<div id="divAlert" class="alert alert-success alert-dismissible"><button class="close" aria-hidden="true" type="button" data-dismiss="alert">×</button><b><i class="icon fas fa-check"></i>' + jsonData.Response_Message + '. Please note the reference number : ' + jsonData.Call_Id + ' for future reference. </b></div>');
console.log(jsonData);
var slctdIndex = idx + 1;
var Call_details = $('#Call_Details').val();
var Contact_No = $('#Contact_No').val();
var Requested_By = $('#Requested_By').val();
var Call_Type = $('#Call_Type_Id1 option:selected').text();
var Product = $('#Product_Id1 option:selected').text();
$('table tr:nth-child(' + slctdIndex + ')').find('td:nth-child(4)').text(Product)
$('table tr:nth-child(' + slctdIndex + ')').find('td:nth-child(5)').text(Call_Type)
$('table tr:nth-child(' + slctdIndex + ')').find('td:nth-child(6)').text(Call_details)
$('table tr:nth-child(' + slctdIndex + ')').find('td:nth-child(7)').text(Requested_By)
$('table tr:nth-child(' + slctdIndex + ')').find('td:nth-child(8)').text(Contact_No)
}
});
之后,将td
值更新为新值。
然后我选择要编辑的行,得到了先前的行数据值,但是我想更新行值
///Edit the table row/////
$('#btnEditCallRegisterTable').click(function () {
var rowToUpdate = [];
if ($('#CallRegisterTable tr.selected').length !== 1) {
alert("Please Select One Row To Edit!!!");
return false;
}
var index = $.SetRowId();
var datatable = $("#CallRegisterTable").DataTable();
//Row to Edit
var EditRow = datatable.cells({ row: index,column: 0 }).data()[0];
// console.log(EditRow);
var jsonObjectUpdateData = {};
$.each(EditRow,function (key,value) {
jsonObjectUpdateData[key] = value;
});
jsonObjectUpdateData["Data_Status"] = 'U';
rowToUpdate.push(jsonObjectUpdateData);
$.CCAjax("/Service/CallRegisterEditForm",{ requestData: jsonObjectUpdateData },function (data) {
$(".call-register-form").html(data);
}
);
});
// CCAjax是定制的ajax调用。 // $。SetRowId()是选定的行索引。
//controller action
[HttpPost]
public ActionResult CallRegisterEditForm(ServiceCallRequestModel requestData)
{
return CCPartialView("_CallRegisterEditForm",requestData);
}
在成功提交表单后更改了行数据之后,我再次选择了该表中的同一行,我的表单使用旧表行数据呈现,但是我需要更新的行数据值。任何人都可以指导我实现这一点。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。