I would like to change size of scrollable area of a datatable.
$('#example').dataTable({"sScrollY": 100});
//some stuff..
$('#example').dataTable({"sScrollY":101}); //wrong: cannot reinitialize
$('.dataTables_scrollBody').css('height', 400);
To change the Y Scroll use the below code,
var objDataTable = $('#example').dataTable({"sScrollY" : 100});
objDataTable.fnSettings().oScroll.sY = 101;
objDataTable.fnDraw();
If yoy have several datatables you can access each by the wrapper:
$('#example').dataTable({'sScrollY': 100});
//some stuff..
objDataTable.fnSettings().oScroll.sY = '225px';
$('#example_wrapper').children('.dataTables_scroll').children('.dataTables_scrollBody').css('height', '225px');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With