live event to replace table contents every 10 secs - example somewhere?

live event to replace table contents every 10 secs - example somewhere?

mikedmiked Posts: 43Questions: 3Answers: 0
edited September 2012 in General
version 1.94, I've searched around but nothing really jumped out at me for this, but I think I'm overthinking this

We have a stream of data, similar in nature to an RSS feed, that hits our site continuously and is fed into a table.

I'm putting a dashboard-like page together for the UI front end and I'd like to add a single column table that shows the last 20 items that have come in from the RSS-like feed that refreshes every 10 seconds. I've got the server side call written that returns the last 20 items, and I'd just replace the entire contents of the table with the new data every 10 in hopes of keeping it simple.

Is there an example somewhere of the live updating that someone that someone could point me to that would get me in the ballpark?

tia

Replies

  • robertmazzorobertmazzo Posts: 22Questions: 0Answers: 0
    you're probably not using asp.net, however I'll point out that I've used an control combined with a control in an old asp.net project using VS2008 and the Ajax Extensions available at the time.
    I'm thinking about a similar scenario as you, where I'd like to auto-refresh my Datatable from time to time (and perhaps make it user-configurable).
    good luck.
  • mikedmiked Posts: 43Questions: 3Answers: 0
    type/language of server side process doesn't really matter, from the datatable side there is just a load call to a url, and the XML/json data comes back as needed

    'sAjaxSource': src= someurl

    this is the closest I've been able to find so far: http://datatables.net/forums/discussion/6650/server-side-auto-refresh-table/p1

    think the answer to my question is in there somewhere, just need to rework the code to my direction
  • mikedmiked Posts: 43Questions: 3Answers: 0
    answer/code towards the bottom of this thread: http://www.datatables.net/forums/discussion/5886/trying-to-reload-data-at-setinterval-but-failing-miserably/p1

    will post my solution if it ends up being different somehow
  • robertmazzorobertmazzo Posts: 22Questions: 0Answers: 0
    indeed post your solution if you find something different that using setInterval(function() { oTable.fnDraw; }, 5000);.

    Allan gave me a great idea this week in terms of refreshing, except it was based on a change event on a dropdown list I implemented. So I'm using fnAddData() after I init the Datatable.

    Perhaps this could be used on a timer as well...

    ex/
    If my datatable is already initialized, then use fnAddData();

    [code]
    var PfJsonData = [];

    $(this).find("id").each(function (){
    PfJsonData.push({"Term": term, "Exposure": exposure });
    }
    if (oTablePf_Initialized == false) {
    oTablePf = $('#pftable').dataTable({ // INIT
    "aaData": PfJsonData,
    });
    oTablePf_Initialized = true;
    }
    else { // CLEAR TABLE AND REPOPULATE
    oTablePf.fnClearTable();
    if (oTableCo_Initialized) {
    oTableCo.fnClearTable();
    }
    oTablePf.fnAddData(PfJsonData, true);
    }

    [/code]
This discussion has been closed.