is there a way to change sScrollY after initiation ?

is there a way to change sScrollY after initiation ?

netametanetameta Posts: 39Questions: 0Answers: 0
edited February 2014 in General
is there a way to change sScrollY after initiation ?

lets say i did

[code]
$(table).dataTable({
"sScrollY": "220px",
});
[/code]

is there a way to remove that and allow the table to go max height ?

i know if i remove the height with JS it makes it look like the sScrollY is gone, but ones you do anything that will redraw the table it get fixed and back to the initial value.

So is there any other way to cancel sScrollY on the fly ? maybe with redraw or something.

Thanks

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Currently no - there is no public API for this. You can hack it using `$('div.dataTables_scrollBody').height( ... );` , or wrap that up into a plug-in if you want :-)

    Allan
  • ShonoShono Posts: 6Questions: 0Answers: 0
    edited February 2014
    I use this to get the window height and resize the table to fit with the controls on screen. It's done for a table with Scroller, but maybe it can help your case.

    [code]if (typeof $dataTable !== 'undefined') {
    var windowHeight = $(window).height();
    // Minimum scrolling height in px
    var minScroll = 200;
    // The sum of the heights of the controls and thead plus an extra margin
    var offsetHeight = 30 + $('#table_filter').height()
    + $('div.dataTables_scrollHead').height();

    // Check if the window is too small to resize
    if ( windowHeight <= (offsetHeight + minScroll) ) {
    $dataTable.fnSettings().oScroll.sY = minScroll+'px';
    } else {
    $dataTable.fnSettings().oScroll.sY = (windowHeight - offsetHeight)+'px';
    }
    // Actual resize with given height
    $dataTable.fnSettings().oScroller.fnMeasure();
    }[/code]

    I call this on ready and resize events. Don't know if it's optimal or not, but it works for me.
  • netametanetameta Posts: 39Questions: 0Answers: 0
    Thanks both, i will simply add a redraw event for now i guess
This discussion has been closed.