Hi Developers ,
i want to save all records one by one using jquery in mvc.
Records bind on a html div.
In this tblDetails having 5 records one by one as gridview. Now i want to get database saved Id of the 5 records and need to store in a single variable. Should Insert the variable value to database.
For Example
Binding Records to me (Jquery html table)
StudentId Name Age
111 Paul1 26
112 Paul2 27
113 Paul3 28
114 Paul4 29
115 Paul5 30
My Expected Output in Jquery
studentId= "111,112,113,114,115" (Split by Comma)
$('#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.");
}
});
$("body").on("click", "#btnSubmitAll", function () {
var TableData;
TableData = storeTblValues()
var myJsonString = JSON.stringify(TableData);
myJsonString = myJsonString.replace(/([.€])+/g, '');
alert(myJsonString)
});
function storeTblValues() {
var TableData = new Array();
$('#tblDetails tr').each(function (row, tr) {
TableData[row] = {
'': $(tr).find('td:eq(0)').text()
}
});
TableData.shift(); // first row will be empty - so remove
return TableData;
}
Thanking you
Paul.S