fnUpdate with server side

fnUpdate with server side

renzosilvrenzosilv Posts: 11Questions: 0Answers: 0
edited October 2012 in DataTables 1.9
I'm using the latest version of DataTables and I am updating some data on the server side. I do not want to re-draw the whole thing however as the information displayed is quite large. I would like to just update the row in order to show the same information on the datatable as my server.
So I have this function where data is an array returned from my server side script with the data which was entered onto the database.
[code]
function(data)
{
if( (data[0]==DeSys.val())&&(data[1]==core.val())&&(data[2]==AD.val())&&(data[3]==Comment.val()))
{
console.log(rowP);
var myvar = [' ', DeSys.val(), core.val() , AD.val(), Comment.val() , ' '];
console.log(myvar);
$('#cores').dataTable().fnUpdate([' ', DeSys.val(), core.val() , AD.val(), Comment.val() , ' '] , rowP ,0 , false);
$('#cores').dataTable().fnStandingRedraw();
}
}
[/code]

I know I am passing the correct information as I have tried it with.
[code]
$('#cores').dataTable().fnAddData([' ', DeSys.val(), core.val(), AD.val(), Comment.val(), ' '], false);
$('#cores').dataTable().fnStandingRedraw();
[/code]
and that seems to work fine.
Should my variable rowP be anything other than just the column number I am trying to update ?

I have also tried giving it the node but it doesn't help. Is there a problem because I have an image in one of my rows ?
Any help would be appreciated.
Thanks

Replies

  • renzosilvrenzosilv Posts: 11Questions: 0Answers: 0
    So I figured what was happening....
    This function
    [code]
    oTable.fnUpdate([' ', DeSys.val(), core.val() , AD.val(), Comment.val() , ' '] , rowP ,0 , false);
    [/code]
    Was adding everything to the first column and since I had a fnRender which was adding an image there, all my data was getting overridden. Making it hard to catch the problem :-p
    I worked around it by adding each column separately... The function description said to leave a zero as the 3rd parameter of the fnUpdate function when adding a whole row. Is that no longer the case ?
  • allanallan Posts: 63,394Questions: 1Answers: 10,451 Site admin
    fnUpdate (and fnAddData, fnDeleteRow) is utterly redundant when using server-side processing. The data is held at the server, so when you want to update the data, you need to update it at the server, and then simply get the table to draw again ( fnDraw ). Otherwise, you'd do the update, and on the next draw the data would revert to what is held at the server (since you haven't told the data source that the data has changed).

    The fnAddData method has this warning in the documentation:

    > Please note that this is suitable for client-side processing only - if you are using server-side processing (i.e. "bServerSide": true), then to add data, you must add it to the data source, i.e. the server-side, through an Ajax call.

    Allan
This discussion has been closed.