DataTables doesn't calculate column width after hidden columns
DataTables doesn't calculate column width after hidden columns
epitaphmike
Posts: 3Questions: 1Answers: 0
DataTables 1.10.8 has an issue calculating the column widths of columns preceding a hidden column.
Looping through the columns to set the width based on the header works fine until the loop hits a hidden column. All visible columns after the hidden column get a width of 0px.
https://s3.amazonaws.com/uploads.hipchat.com/49969/341159/yAEAOQzBpuBaPxP/upload.png
This discussion has been closed.
Answers
This looks like a cross post from GitHub. Could you post questions only in one place please - tracking the same problem over two locations just adds overhead :-).
As noted in the GitHub issue, can you link to a test case showing the issue please. I've tried to reproduce the issue and was unable to do so.
Allan
Hi, I've also been wondering if there's something off in 1.10.8 about computing column widths.
I can work on trying to create an example, but e.g. even the API table seems not quite right: https://datatables.net/reference/api/
I tested in Firefox, Chrome and Safari, and in all three the "name" column is about five times wider than the "summary" which seems odd, since the summary column contains more content.
Perhaps my problem is just in understanding the autoWidth option. In my tables when I set autoWidth to false the columns get sized a lot more like I would expect, i.e. columns with all short values are narrower.
That sounds very odd. It should be around a 1:3 split, which is what I see in Chrome Mac.
Having said that, if you are on a mobile browser or have a narrow width browser window, then what you see might be caused by the fact that I don't let DataTables split the 'name' column text. So the widest string in the column will force the width for the whole table.
Allan
Something strange is afoot then. Here's a screenshot of how it looks for me on Chrome Mac (v. 44.0.2403.157 (64-bit)): http://ibin.co/2DTgNxDlpXEn
It seems to be the same scrollbar hiding issue with OSX.
With scrollbars always showing in General Setting on OSX
https://s3.amazonaws.com/uploads.hipchat.com/49969/341159/4CyT81ieyXLjeU3/upload.png
You see the columns width as normal.
https://s3.amazonaws.com/uploads.hipchat.com/49969/341159/9fWG3EYylpQmX2P/upload.png
With scroll bars set to Automatically based on mouse or trackpad
https://s3.amazonaws.com/uploads.hipchat.com/49969/341159/dSwbX40Lvr8bFVa/upload.png
You see the columns with the incorrect width.
https://s3.amazonaws.com/uploads.hipchat.com/49969/341159/lWp2InkUzzbQST1/upload.png
Once these pages use 1.10.9 release, all should be good.
Reference here for more context
https://github.com/DataTables/DataTables/issues/633