api to scroll to last row.

api to scroll to last row.

prubinprubin Posts: 26Questions: 0Answers: 0
edited December 2011 in General
I am trying to make a table that has rows added every few seconds and would like the table to automatically scroll to the last row after each add (unless paused). (think tail) I am using the scroller extra, but this code does not seems to work:

[code]
oSettings.oScroller.fnScrollToRow( 9999999 )
[/code]

I originally tried using the row number of count of total rows and that did not work, so I just tried a really big number and that did not work either.

Also, if it tells you anything, I am tripping the glitch in scroller when rows wrap. So I might be at "Showing 431 to 416 of 416 entries" at the bottom.

Thanks
Paul.

Replies

  • prubinprubin Posts: 26Questions: 0Answers: 0
    Turns out I can just directly manipulate the scroll body div:
    [code]
    LogGrid.processNext = function(json) {
    var oSettings = LogGrid.fnSettings();
    var scroller = LogGrid.parent()[0];
    var oldTop = scroller.scrollTop;
    var aData = oSettings.sAjaxDataProp(json);
    /* Got the data - add it to the table */
    if (aData.length > 0) {
    for (i = 0; i < aData.length; i++) {
    LogGrid.fnAddData(aData[i]);
    }
    if (oSettings.oFeatures.bSort) {
    LogGrid.fnSort(oSettings.aaSorting);
    }
    if (LogGridTailing.attr('checked')) {
    scroller.scrollTop = scroller.scrollHeight;
    } else
    scroller.scrollTop = oldTop;
    }
    }
    [/code]
    where LogGrid = $('#Log').dataTable( ... )
This discussion has been closed.