Jquery - changing sScrollY data

I would like to resize the scrollable area in datatable.

$('#example').dataTable({"sScrollY": 100}); //some stuff.. $('#example').dataTable({"sScrollY":101}); //wrong: cannot reinitialize 
+6
source share
5 answers
 $('.dataTables_scrollBody').css('height', 400); 
+6
source

To change the Y-scroll, use the code below,

 var objDataTable = $('#example').dataTable({"sScrollY" : 100}); objDataTable.fnSettings().oScroll.sY = 101; objDataTable.fnDraw(); 
+4
source

If yoy has several data types, you can access each shell:

 $('#example').dataTable({'sScrollY': 100}); //some stuff.. objDataTable.fnSettings().oScroll.sY = '225px'; $('#example_wrapper').children('.dataTables_scroll').children('.dataTables_scrollBody').css('height', '225px'); 
+2
source

For jquery.dataTables 1.10.x:

 $('div.dataTables_scrollBody').height( 400 ); 

This is the recommended method according to the datatables documentation. According to the same documentation, using the settings object is not recommended because it is internal.

+1
source

I had to combine both solutions of my problem. In my case, I want to do an infinite pagination, the problem is that after resizing the window, the height of the dataTables_scrollBody remains fixed, so I need to configure oScroll to display the table data by scrolling. Setting the height of dataTables_scrollBody will work when the window is resized, but after redrawing the table, it will be rolled back using the old sScrollY value, and the Neo code fixed it. :)

 objDataTable.fnSettings().oScroll.sY = 101; objDataTable.fnDraw(); $('.dataTables_scrollBody').css('height', 400); 
0
source

All Articles