ServerSide processing and local update of a single row W/O doing an ajax call
ServerSide processing and local update of a single row W/O doing an ajax call
I'm struggling a bit on that.
I have a datatable with server side processing. I have the possibility to edit some values and to post them to the server.
I wish then to refresh the modified row with the updated data for the row without
-1- redrawing the whole table
-2- regeting the data from the server
I tried to play a bit with fnUpdate but the guy is calling fnReDraw so I'm busted.
Any suggestion'r welcomed
cheers
/tm
I have a datatable with server side processing. I have the possibility to edit some values and to post them to the server.
I wish then to refresh the modified row with the updated data for the row without
-1- redrawing the whole table
-2- regeting the data from the server
I tried to play a bit with fnUpdate but the guy is calling fnReDraw so I'm busted.
Any suggestion'r welcomed
cheers
/tm
This discussion has been closed.
Replies
here's a hack-ish way you can re-trigger fnRender after fnUpdate'ing the data (run this for every TD in the row):
note: the way i have it written relies on a global "oTable" variable. if you don't use a global, just rewrite the params to require oTable or retrieve oTable yourself with a call to .dataTable()
[code]
// repaint a cell with its column's render function
function fnRepaint(nTd) {
if (typeof nTd === "undefined") nTd = this;
// get internal index pointer to data in DataTables for this TD element
var aPos = oTable.fnGetPosition( nTd );
var iRow = aPos[0];
var iCol = aPos[1];
// get the Column object representing the column this TD belongs to
var oSettings = oTable.fnSettings();
var oCol = oSettings.aoColumns[iCol];
// if the column has a render function, call the function
if (typeof oCol.fnRender === "function") {
var oData = oSettings.aoData[iRow]._aData;
var oObj = {
iDataRow: iRow,
iDataColumn: iCol,
aData: oData
}
nRow = oTable.fnGetNodes(iRow);
$('td', nRow).eq(iCol).html(oCol.fnRender(oObj));
}
// turn off processing message
$('.dataTables_processing').hide();
}
[/code]
btw, in your code, line 24, you should prefer the following selector:
$('>td',nRow)
in order to have only the dataTable TD, not the ones that may be in the cell (as I have ;))
thx very much for ur help