Step 1: Add the jquery main file.
Step 2: Add the following Code.
function saveValues( ) {
var tableMatRequire = [];
$('#matReqTable tr').each(function (row, tr) {
tableMatRequire.push({
IndentNo: $('.indentClass').val(),
MatReqName: $(tr).find('td:eq(1)').find('#matReqPart').val(),
MatQuantity: $(tr).find('td:eq(2)').find('#matReqQuant').val()
});
});
tableMatRequire.shift();
sendData(tableMatRequire);
}
Note: Here 'matReqTable' is the table ID,
matReqPart is the table column id, here it is textbox, if you have label then just do,
MatReqName: $(tr).find('td:eq(1)').val(),
Step 3: In the above step we have save the dynamic table values in an array..
Now, pass this array by ajax to the server control function :
Add the following code :
function sendData(tableMatRequire)
{
$.ajax({
type: "POST",
url: "/Indent/Index", // Here pass the required url
dataType: "json",
contentType: "application/json",
data: JSON.stringify({
MatReq: tableMatRequire,
}),
success: function (data) {
alert("Data send !");
}
});
}
No comments:
Post a Comment