Initializing data
Initializing data
Hi,
When I use PHP to load the page with data by default everything works great.
However, when I want to load different data without refreshing the page through javascript I have some problems.
This code displays the new data unformatted.
[code]
$.getJSON("test.php",
function(data){
var tbody_output = "";
$.each(data.grid, function(i,item){
tbody_output += ""+item.ipID+""+""+item.address+""+""+item.station_id+""+""+item.iptype+""+""+item.host_type_id+""+""+item.status+""+""+item.fw_status+""+""+item.notes+""+"Altigen Info"+"Action";
});
$("#example tbody").html(tbody_output);
});
[/code]
Adding oTable.fnDraw(); displays no data at all.
Adding oTable.fnReDraw(oTable.fnSettings()); or oTable.fnReDraw(oSettings); says Object doesn't support this property or method.
Alternatively, adding each row in a loop with oTable.fnAddData does work but is very slow and causes a warning that the page is running a script to long.
Any advice would be appreciated.
Thanks.
When I use PHP to load the page with data by default everything works great.
However, when I want to load different data without refreshing the page through javascript I have some problems.
This code displays the new data unformatted.
[code]
$.getJSON("test.php",
function(data){
var tbody_output = "";
$.each(data.grid, function(i,item){
tbody_output += ""+item.ipID+""+""+item.address+""+""+item.station_id+""+""+item.iptype+""+""+item.host_type_id+""+""+item.status+""+""+item.fw_status+""+""+item.notes+""+"Altigen Info"+"Action";
});
$("#example tbody").html(tbody_output);
});
[/code]
Adding oTable.fnDraw(); displays no data at all.
Adding oTable.fnReDraw(oTable.fnSettings()); or oTable.fnReDraw(oSettings); says Object doesn't support this property or method.
Alternatively, adding each row in a loop with oTable.fnAddData does work but is very slow and causes a warning that the page is running a script to long.
Any advice would be appreciated.
Thanks.
This discussion has been closed.
Replies
Have a look at this plug-in which will allow reloading of the Ajax data source: http://datatables.net/plug-ins/api#fnReloadAjax
Regards,
Allan
The thing that really kills sorting with a lot of data is the highlighted sorting column class. This can be disabled using http://datatables.net/usage/features#bSortClasses , and will yield a big improvement for 1200 rows.
Regards,
Allan