Initializing data

Initializing data

jriverajrivera Posts: 14Questions: 0Answers: 0
edited January 2010 in General
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.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi jrivera,

    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
  • jriverajrivera Posts: 14Questions: 0Answers: 0
    Thanks for the quick response. This seems to work, however it is still a bit slow to load 1200 rows, 10 columns each as well as subsequent sorts (filtering seems to remain quick though). I guess I'll have to switch over to server side processing.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi jrivera,

    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
  • jriverajrivera Posts: 14Questions: 0Answers: 0
    You're the best!
This discussion has been closed.