How to update changes to cells in DataTables with Server Side?

How to update changes to cells in DataTables with Server Side?

kdar1987kdar1987 Posts: 9Questions: 3Answers: 0
edited February 2014 in General
I was following DataTables with form elements example http://datatables.net/release-datatables/examples/api/form.html to add submit form and to update my database when I make changes on DataTable with Server Side.

My script looks like this:
[code]
var oTable;

$(document).ready(function () {
$('#SaveTable').submit( function() {
var sData = $('input', oTable.fnGetNodes()).serialize();
alert( "The following data would have been submitted to the server: \n\n"+sData );
return false;
} );

oTable = $('#LeaveApproval').dataTable({
"bLengthChange": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "LeaveApproval_Server_Side.asp<%=ProgramString %>",
"aoColumnDefs": [
{
"fnRender": function ( oObj ) {
return ' ';
},
"aTargets": [ 8 ]
}
],
"aaSorting": [[ 1, "asc" ]]
} );
});
[/code]
In my code, I have one of the columns as a textbox, that gets populated by data from database, but which I also want to be able to modify and then submit changes. Can anyone help me understand how I can update database when I use DataTable with Server Side?

What do I have to do with sData string that gets returned with alert? How can I pass it to update database when I use DataTable with Server Side?

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    > Can anyone help me understand how I can update database when I use DataTable with Server Side?

    You need to use jQuery's Ajax method (or any other form of communicating with the server if you want to use something else) to tell the server that the data has changed. DataTables itself has no "back channel" to tell the server about new data.

    Allan
  • kdar1987kdar1987 Posts: 9Questions: 3Answers: 0
    Thanks Allan.
    I ended up just passing that sData generated string to another page to update SQL database.
This discussion has been closed.