Make sScrollY dynamic?
Make sScrollY dynamic?
Taylor514ce
Posts: 74Questions: 8Answers: 0
I have "sScrollY" : $(document).height() - 260
When the window is resized, this isn't recalculated. I see the fnColumnAdjust api, is there a similar api to adjust the number of rows, or otherwise redraw the table with a new sScrollY value?
When the window is resized, this isn't recalculated. I see the fnColumnAdjust api, is there a similar api to adjust the number of rows, or otherwise redraw the table with a new sScrollY value?
This discussion has been closed.
Replies
[code]
$(window).bind('resize', function () {
$(".dataTables_scrollBody").height($(document).height() - 260);
myTable.fnDraw();
});
[/code]
Ultimately I think this should be wrapped up into a plug-in API method, but yes, that looks good :-)
Allan
[code]
$('.dataTables_scrollBody', table.fnSettings().nTableWrapper)
[/code]
Or, if you have the table node already, you could use:
[code]
tableNode.parentNode;
[/code]
Allan
On the resize event, you "manually" change the height of an element renderered by datatables component. Ok.
But as you didn't change the sScrollY value, when you call the fnDraw() method, the initial rendering is called once again, and the height is fixed by the old sScrollY value once again.
I'm right ?
[code]
$(window).bind('resize', function () {
var NewHeight = $(document).height() - 260;
var oSettings = myTable.fnSettings();
oSettings.oScroll.sY = NewHeight + "px";
myTable.fnDraw();
});
[/code]