Dynamically change the height of "sScrollY"
Dynamically change the height of "sScrollY"
dajones12
Posts: 5Questions: 3Answers: 0
Hello,
I'm a complete beginner here, so I apologize if this is a simple question. How do I go about making the height of my table dynamic based on the rows in it? My current code is:
$(document).ready(function() {
var oTable = $('#displayTable').dataTable( {
"bPaginate": true,
"processing": true,
"bDeferRender": true,
"bAutoWidth": true,
"sScrollY": "300px",
"bStateSave": true,
"sDom": '< TC > ftiS',
"oTableTools": {
"sSwfPath": "js/copy_csv_xls.swf",
"aButtons": [
"copy",
"print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "xls" ]
}
]
},
Ideally, I would like for it to have a max height of 300px, but be shorter if there are fewer rows.
Thanks!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
https://datatables.net/reference/option/scrollCollapse
Use this
I tried that and for some reason it had no effect on my table.
Based on your code, you appear to be using an older version of DataTables. I believe scollCollapse is a fairly new option.
I just got it working. You were correct. I just had to add a "b" to the front of it. So:
"bScrollCollapse": true
worked for me.
Thanks for the help!
scrollCollapse
for 1.10+, and bScrollCollapse for the legacy interface.Allan