fnUpdate with server side
fnUpdate with server side
renzosilv
Posts: 11Questions: 0Answers: 0
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
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
This discussion has been closed.
Replies
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 ?
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