Paul Rajs

Paul Rajs

  • 1.4k
  • 498
  • 53.1k

How to get and save to db in all gridview records in mvc jqu

May 23 2020 4:55 AM
Hi Developers ,
i want to save all records one b yone using jquery in mvc , below i have added using code ...
javascript
function GetDetails() {
IsLoading(true);
$("#divDataTableContent").addClass("hide");
var myData =
{
FromDate: FromToDate.split("-")[0],
ToDate: FromToDate.split("-")[1]
}
$.ajax({
type: "POST",
url: pathIndex("Recon") + '/Recon/GetPGReversal',
dataType: "json",
data: AddAntiForgeryToken(myData),
success: function (response) {
if (response.ResponseCode == 0) {
BindTitle();
$("#divDataTableContent").removeClass("hide");
}
else if (response.ResponseCode == 500 || response.ResponseCode == 504) {
window.location.href = response.RedirectUrl;
}
else {
$().toastmessage('showNoticeToast', response.Message);
}
IsLoading(false);
},
failure: function (response) {
swal(_SharedFailureResponseHeading, _SharedFailureResponseContent, "error");
IsLoading(false);
},
error: function (response) {
swal(_SharedErrorResponseHeading, _SharedErrorResponseContent, "error");
IsLoading(false);
}
});
}
function BindTitle() {
$.ajax({
type: "POST",
url: pathIndex("ReconReports") + '/GenericReport/GetTitle?viewdataName=PaymentPGReversal_Temp',
dataType: "json",
contentType: "application/json",
success: function (response) {
BindTable(JSON.parse(response.ResponseContent));
}
});
}
function BindTable(title) {
if ($.fn.DataTable.isDataTable('#tblDetails')) {
$('#tblDetails').DataTable().destroy();
}
$('#tblDetails').dataTable({
"processing": true, // control the processing indicator.
"serverSide": true, // recommended to use serverSide when data is more than 10000 rows for performance reasons
"info": true, // control table information display field
"stateSave": false, //restore table state on page reload,
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]], // use the first inner array as the page length values and the second inner array as the displayed options
"pageLength": 100,
"ajax": {
"url": pathIndex("ReconReports") + '/GenericReport/GetData?viewdataName=PaymentPGReversal_Temp',
"type": "POST",
"contentType": "application/json",
"dataType": "JSON",
"data": function (d) {
return JSON.stringify(d);
},
"dataSrc": function (json) {
var jsonp = JSON.parse(json.ResponseContent);
json.draw = jsonp.draw;
json.recordsTotal = jsonp.recordsTotal;
json.recordsFiltered = jsonp.recordsFiltered;
json.data = jsonp.data;
var return_data = json;
return return_data.data;
}
},
"columns": title,
dom: 'Bfrtip',
buttons: [
{
text: '<i class="fa fa-file-excel-o"> Excel</i>',
action: function (e, dt, node, config) {
ExportExcel();
}
},
{
text: '<i class="fa fa-file-pdf-o"> PDF</i>',
action: function (e, dt, node, config) {
ExportPDF();
}
},
],
responsive: true,
"fnDrawCallback": function (oSettings) {
},
"order": [[0, "asc"]],
"error": function () {
alert("DataTables warning: JSON data from server failed to load or be parsed. " +
"This is most likely to be caused by a JSON formatting error.");
}
});
}
If anyone know how to done this module kindly let me know ...
Thanking you
Paul.S

Brought to you by:

Answers (1)