Colvis hiding columns makes the rest of the columns wider
Colvis hiding columns makes the rest of the columns wider
fearednerd
Posts: 44Questions: 0Answers: 0
I was wondering if there was a way to let the column widths stay fixed after hiding a column. I have a lot of columns and trying to keep the table width reasonable, but when I hide columns by default the unused width space gets redistributed to the rest of the columns.
This discussion has been closed.
Replies
Allan
http://datatables.net/release-datatables/extras/ColVis/
If you hide all the columns but one, the one remaining column gets wider instead of maintaining its width.
I was wondering if there was a way to get them to stay the same width whether or not a column gets hidden.
[code]
"aoColumnDefs": [
{ "sWidth": "70px", "aTargets": [ "staticWidthColumn" ] }
],
[/code]
Any column with a class of staticWidthColumn will always be 70px wide.
This then poses an issue that the header will always be centered while the data shifts to the left. To fix this i added the following lines to the jquery.data.Tables.js. I'm sure there is a better way to do this with css but i havent gotten there yet.
This goes in about line #3085
[code]
nScrollHead.align = "left";
nScrollHeadInner.align = "center";
[/code]