Adjusting Table Height After Adding/Removing Rows
Adjusting Table Height After Adding/Removing Rows
tolyan
Posts: 2Questions: 0Answers: 0
Hello All,
First, want to say that this is a great plugin! Thanks Allan! I've been using it quite extensively. After struggling some as a newbie, I got most of the functionality down. But I do hit the wall with the following issue. I have a page where I'm displaying multiple dataTables to show a lot of diff. info in the grid-like way with ajax data loading. Some of the tables can be empty, some have expandable details. The problem that I can't seem to figure out - if you expand last row, user can't immediately see it. I can set the bScrollCollapse=false, but then all other tables that are empty will have a fixed height that take a lot of real estate on the page (I have 20+ tables). It is especially a problem if the table has only 1 row loaded and the user needs to expand details on it - you can't even notice the change. I have tried to use jQuery to resize the dataTables_scrollBody after creating the detailed row, but that didn't work and I can't even select it (it's just not there?..). Also, any changes to css result in messing up the original data for details and re-grabs the "new" values. As alternative to adjusting the height, I have tried to set bScrollCollapse=false and if the table has no data, set it to true. But I couldn't find the solution for that either. Has anyone else come across something like this? Any ideas would be appreciated.
First, want to say that this is a great plugin! Thanks Allan! I've been using it quite extensively. After struggling some as a newbie, I got most of the functionality down. But I do hit the wall with the following issue. I have a page where I'm displaying multiple dataTables to show a lot of diff. info in the grid-like way with ajax data loading. Some of the tables can be empty, some have expandable details. The problem that I can't seem to figure out - if you expand last row, user can't immediately see it. I can set the bScrollCollapse=false, but then all other tables that are empty will have a fixed height that take a lot of real estate on the page (I have 20+ tables). It is especially a problem if the table has only 1 row loaded and the user needs to expand details on it - you can't even notice the change. I have tried to use jQuery to resize the dataTables_scrollBody after creating the detailed row, but that didn't work and I can't even select it (it's just not there?..). Also, any changes to css result in messing up the original data for details and re-grabs the "new" values. As alternative to adjusting the height, I have tried to set bScrollCollapse=false and if the table has no data, set it to true. But I couldn't find the solution for that either. Has anyone else come across something like this? Any ideas would be appreciated.
This discussion has been closed.
Replies
@nibl - Sounds like you want a min-height on the div.dataTables_scrollBody class in CSS?
Allan
in the dataTables constructor:
$('#myTable').dataTable( {
... somewhere here add:
"fnDrawCallback": function( oSettings ) {
$('.dataTables_scrollBody').css('min-height', '100px');
},
...
} );