Hiding tables for update

Hiding tables for update

wimsterwimster Posts: 1Questions: 0Answers: 0
edited August 2009 in General
Hi all,

Just started using DataTables for a dashboard project.

JSON provides the data on which the table is based and is periodically updated which requires a refresh of the table. So far, I have implemented this as clearing the table followed by effectively filling it from scratch:

[code]
myTable.fnClearTable();
$.getJSON("sample.json", function(json){
processJSON(json); /*processes JSON and fills myTable*/
});
[/code]

Although this works, the table flickers between content and the 'No matching columns' message. How would I be able to prevent this from happening? Is there a mechanism that allows me to effectively switch off table redraw while I update the content?

Thanks for your help!

Wimster

Replies

  • allanallan Posts: 54,909Questions: 1Answers: 8,606 Site admin
    Hi Wimster,

    One quick little change to your code should do the trick:

    [code]
    $.getJSON("sample.json", function(json){
    myTable.fnClearTable();
    processJSON(json); /*processes JSON and fills myTable*/
    });
    [/code]
    Also, just incase you missed it, there is the fnReloadAjax function ( http://datatables.net/plug-ins/api#fnReloadAjax ) which you might be interested in (although, you've basically re-implemented it here!).

    Regards,
    Allan
This discussion has been closed.