Editable Ajax

Editable Ajax

secondaccsecondacc Posts: 5Questions: 0Answers: 0
edited April 2011 in General
I recently upgraded from Datatables 1.6.x to 1.7.6.
I used to be able to edit table cells just fine.
Now I notice that after editing, there is another ajax call and the whole table is being rebuilt. It used to just update the cell that was edited.

Here is a part of my code:
[code]
"sAjaxSource": "/js/datatables.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push(
{"name":"table", "value":"updates"}
);
$.ajax({
"dataType": 'json',
"type": 'POST',
"url": sSource,
"data": aoData,
"success": fnCallback
});
},
"fnDrawCallback": function () {
//edit in place
$('#table tbody td:nth-child(3),#table tbody td:nth-child(4),#table tbody td:nth-child(5)').editable('/js/ajax.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
var aPos = oTable.fnGetPosition( this );
var aData = oTable.fnGetData( aPos[0] );
return {
"column": aPos[1],
"id": aData[1],
"type": "updates"
};
},
indicator: ''
});
} //fnDrawCallback
[/code]
The ajax.php just returns the value that was entered.
How do I make it so that there is not another ajax request for the full table?

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    http://datatables.net/api#fnUpdate - pass a fourth parameter to fnUpdate (false), which will prevent the redraw.

    Allan
  • secondaccsecondacc Posts: 5Questions: 0Answers: 0
    Thank you very kindly, Allan! That solved the problem.
    What I don't quite understand is that on other pages with the same setup (and without the fourth paramter), the problem did not occur.
    I'll add the parameter to all the editable function calls now, just to make sure.
This discussion has been closed.