Hardly i find out the way to handle table data.To post large collection of data into controller using form might not be a good approach even if we don't have any input type html element.
Step 1: Read all table data by iterating through each cell using Java script.
step 2: Add cell element into array by specifying the column counter.
step 3 After completing the each row,add the array into jsonobject.
step 4: Once the iteration complete stringfy the json object and using Ajax pass the Json string to the controller.
<script type="text/javascript">
function GetCellValues(dataTable)
{
var jsonObj = [];
var jsonString;
var table = document.getElementById(dataTable);
for (var r = 0, n = table.rows.length; r < n; r++) {
var item = {};
for (var c = 0, m = table.rows[r].cells.length; c < m; c++){
if(c == 1){
item ["data1"] =table.rows[r].cells[c].innerHTML;}
else if(c==2){
item ["data2"] =table.rows[r].cells[c].innerHTML;}
else if(c==3){
item ["data3"] =table.rows[r].cells[c].innerHTML;}
else if(c==4){
item ["data4"] = table.rows[r].cells[c].innerHTML;}
else if(c==5){
item ["data5"] =table.rows[r].cells[c].innerHTML;}
}
jsonObj.push(item);
}
jsonString = JSON.stringify(jsonObj);
alert("Save your data "+ jsonString);
$.ajax({
type: "POST",
url : "tableData.htm?jsonData="+jsonString,
success: function(data){
$("#").html(data);
},
error:function(data){
console.log("failure"+data);
alert("failure"+data);
}
});
}
</script>