Data is shown twice inside datatabels - double amount of rows
Data is shown twice inside datatabels - double amount of rows
Hi all!
I have the following problem:
I have a server generated json object with 2 rows of data.
But for some non repeatable reason it sometimes occurs that 4 rows are displayed in datatables.
The amount of rows is simply doubled.
Look here: http://img33.imageshack.us/img33/6199/datatwotimes.png
This is what happens on my web-page:
[code]
/** There is NEW data available....**/
newVal=$_GET['newVal'];
oTable = $('#myTable').dataTable( {
...
"sAjaxSource": "getData.php?x="+newVal
...
});
/** because the table won't refresh its data **/
oTable.fnReloadAjax();
[/code]
now... SOMETIMES the double amount of datarows is shown.
why? how can i prevent datatbels of doing this?
Hope you understood my problem, thanks in advance!
//christina
I have the following problem:
I have a server generated json object with 2 rows of data.
But for some non repeatable reason it sometimes occurs that 4 rows are displayed in datatables.
The amount of rows is simply doubled.
Look here: http://img33.imageshack.us/img33/6199/datatwotimes.png
This is what happens on my web-page:
[code]
/** There is NEW data available....**/
newVal=$_GET['newVal'];
oTable = $('#myTable').dataTable( {
...
"sAjaxSource": "getData.php?x="+newVal
...
});
/** because the table won't refresh its data **/
oTable.fnReloadAjax();
[/code]
now... SOMETIMES the double amount of datarows is shown.
why? how can i prevent datatbels of doing this?
Hope you understood my problem, thanks in advance!
//christina
This discussion has been closed.
Replies
I resolved it by calling [oTable.oApi._fnClearTable(oTable.fnSettings());] inside my [fnServerData] method just prior to [fnCallback].
The best solution is to ensure that [fnReloadAjax()] is not callable until after your page and all the tables are fully loaded.
[code]
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function (data, textStatus, jqXHR)
{
oTable.oApi._fnClearTable(oTable.fnSettings());
fnCallback(data, textStatus, jqXHR);
}
});
}
[/code]