Iterate over rows, get data from each cell
Iterate over rows, get data from each cell
krokonoster
Posts: 10Questions: 0Answers: 0
I add rows to my datatable as the user enter data (oTable.fnAddData(....). Works fine.
However, upon submit I want to save the records by posting each row (or all??) to a server action method via ajax.
Not sure what is the right api call to get all rows, or iterate over rows and reading data?
(Will keep looking while waiting for an answer)
However, upon submit I want to save the records by posting each row (or all??) to a server action method via ajax.
Not sure what is the right api call to get all rows, or iterate over rows and reading data?
(Will keep looking while waiting for an answer)
This discussion has been closed.
Replies
[code]
$('#btnSubmit').click(function (event) {
var nNodes = oTable.fnGetNodes();
if (nNodes.length < 1) {
alert("Please add at least one exception.");
return;
}
var sData = $('input', oTable.fnGetNodes()).serialize();
alert("The following data would have been submitted to the server: \n\n" + sData);
return false;
});
[/code]
However, allthough a few rows was added to the table (at runtime), sData is just empty.
[code]
var nodes = oTable.fnGetNodes();
var data = $('input', nodes).serialize();
alert(nodes.length); // fine..give me # rows in table
alert("Data is: " + data); // nope. empty
alert(data.length); // nope. 0
event.preventDefault();
[/code]