I started playing with jQuery Datatables Plugin and got the table/cell change from display text to a textbox when user click on the display text. Now, my next step is to save this information on the database record after user edited the value in the cell.
This is my code for the editable table.
/* Init DataTables */
var oTable = $('#tblAmount').dataTable({
"bPaginate": false,
"bFilter" : false,
"bInfo" : false
});
/* Apply the jEditable handlers to the table */
oTable.$('td').editable( 'ajaxUpdateAmount.asp', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition( this )[2]
};
},
"height": "14px",
"width": "100%"
} );
The table like this below:
<table cellpadding="0" cellspacing="0" border="0" class="display" id="tblAmount">
<thead>
<tr>
<th>RecordID</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>123</td>
<td>$1,000</td>
</tr>
</tbody>
</table>
Any advice about:
1) How to send the recordID to the ajax page?
2) How to actually see the ajax page updating after the value change in the cell? maybe display in the DIV or something?
Please provide a sample code if possible.
Thank you,