ServerSide Processing and fnAddData
ServerSide Processing and fnAddData
Hello all,
What i have decided to use DataTables for my application , I really liked datatables yet i am having some difficulties since i am not really an expert with jquery and web dev. Perhaps some of you can give me some pointers.
Data i am working with requires server side processing... and i implemented it with out any problems till i need to change the table content on a button function.
i.e.
[code]
$("#input").dialog({
bgiframe: true,
autoOpen: false,
height: 300,
modal: true,
buttons: {
'OK': function(){
$.getJSON('get_data.php', {'action':'query','start': $('#start').val(),'finish': $('#finish').val()},function(json){
oTable.fnClearTable(0);
oTable.fnAddData(json.aaData);
oTable.fnDraw();
//alert(json.aaData);
// oTable.fnReloadAjax(json);
});
$(this).dialog('close');
}
[/code]
when,
[code]'bServerSide':false[/code]
the page loads first time it has to load the initial data with out any filtering , then i send start and finish and send the result back to the datatables .
In total, it performs 2 GETs first for initial load , second for the filtering with start and end and it works perfectly alright BUT when
[code]'bServerSide':true[/code]
datatables sends way too many GETs so i cant display the filtered results and it always displays the initial data.
when i checked firebug it made 3 extra GETS each for ;
[code]Table.fnClearTable(0);
oTable.fnAddData(json.aaData);
oTable.fnDraw();[/code]
I want to made pagination via server side processing yet i want to preserve the filtered state.I tried to use 2 different datasources ... yet couldnt solve it
any ideas?
I hope i explained it in an understandable way.
Thanks in Advance
What i have decided to use DataTables for my application , I really liked datatables yet i am having some difficulties since i am not really an expert with jquery and web dev. Perhaps some of you can give me some pointers.
Data i am working with requires server side processing... and i implemented it with out any problems till i need to change the table content on a button function.
i.e.
[code]
$("#input").dialog({
bgiframe: true,
autoOpen: false,
height: 300,
modal: true,
buttons: {
'OK': function(){
$.getJSON('get_data.php', {'action':'query','start': $('#start').val(),'finish': $('#finish').val()},function(json){
oTable.fnClearTable(0);
oTable.fnAddData(json.aaData);
oTable.fnDraw();
//alert(json.aaData);
// oTable.fnReloadAjax(json);
});
$(this).dialog('close');
}
[/code]
when,
[code]'bServerSide':false[/code]
the page loads first time it has to load the initial data with out any filtering , then i send start and finish and send the result back to the datatables .
In total, it performs 2 GETs first for initial load , second for the filtering with start and end and it works perfectly alright BUT when
[code]'bServerSide':true[/code]
datatables sends way too many GETs so i cant display the filtered results and it always displays the initial data.
when i checked firebug it made 3 extra GETS each for ;
[code]Table.fnClearTable(0);
oTable.fnAddData(json.aaData);
oTable.fnDraw();[/code]
I want to made pagination via server side processing yet i want to preserve the filtered state.I tried to use 2 different datasources ... yet couldnt solve it
any ideas?
I hope i explained it in an understandable way.
Thanks in Advance
This discussion has been closed.
Replies
The thing here is that some of the API functions are really client-side only (I'm going to add a note to the documentation shortly about this). For example with fnAddData - since the data is on the server and DataTables doesn't know anything about your data (if it's in a Postgres database or whatever) - so you need to add the data to the server yourself (send an XHR to add the data) and then just call fnDraw().
Regards,
Allan