Server side data, with periodic updating

Server side data, with periodic updating

writes_onwrites_on Posts: 11Questions: 0Answers: 0
edited February 2012 in General
Hi all,

I'm using DataTables v1.9.0 (thanks for the update!) and I want to update my table with Ajax using the built in methods to get data from the server. I'd also like to update my table periodically using a setTimeout() method that calls DataTables so all of the pagination, sorting, etc. keep working. Is there a way to tie a periodic timer to DataTables?

Thanks,
Doug

Replies

  • apelsinasapelsinas Posts: 1Questions: 0Answers: 0
    edited February 2012
    Hi, you can do like that:
    1) add to your table in order to remember the state (it creates cookie) [code] "bStateSave": true [/code]
    2) and then set autorefresh (in example I have periodic refresh each 30s)
    [code]
    setInterval(function() {
    oTable.fnDraw(false);
    },30000);
    [/code]
  • michandrzmichandrz Posts: 12Questions: 0Answers: 0
    edited February 2012
    @apelsinas, I don't believe that will update the ajax...i could be wrong.
    the way i did it was with the normal table call and then right after doing:
    [code]
    setInterval(function() {otable.fnReloadAjax(null)}, 5000);
    [/code]
    make sure you change 5000 to what ever time in seconds that you want it to refresh x 1000
  • writes_onwrites_on Posts: 11Questions: 0Answers: 0
    Thanks to both of you for the replies, both helpful and insightful!
This discussion has been closed.