Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery - datatable change sScrollY

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
like image 938
nagy.zsolt.hun Avatar asked Feb 04 '13 11:02

nagy.zsolt.hun


3 Answers

$('.dataTables_scrollBody').css('height', 400);
like image 88
nagy.zsolt.hun Avatar answered Oct 28 '22 01:10

nagy.zsolt.hun


To change the Y Scroll use the below code,

var objDataTable = $('#example').dataTable({"sScrollY" : 100});
objDataTable.fnSettings().oScroll.sY = 101;
objDataTable.fnDraw();
like image 27
Neo Avatar answered Oct 28 '22 01:10

Neo


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');
like image 3
Carlos Cuesta Avatar answered Oct 28 '22 02:10

Carlos Cuesta