When use the autoWidth with column width options simultaneously, it cause a problem

When use the autoWidth with column width options simultaneously, it cause a problem

jungyongwoojungyongwoo Posts: 2Questions: 0Answers: 0

https://github.com/DataTables/DataTables/issues/821

When use the autoWidth with column width options simultaneously, column width is not work.

Solution: if use autoWidth value is false and use column width option then should apply to CSS(table-layout: fixed to Table tag)
(Test case URL : https://jsfiddle.net/uyxydn7v/)

Thank you :D

Replies

  • allanallan Posts: 61,934Questions: 1Answers: 10,154 Site admin

    Thanks for the link - much appreciated! The issue is what to do with conflicts. The table has width:100% applied to it, and the fiddle window you linked to (in my specific setup) is 717px wide. That's enough for 2 and a bit columns at 300px.

    So what's a browser to do? This isn't something that DataTables decides - it leaves the table layout algorithms to the browser. I did take a look at the HTML spec for table layout and quickly gave up even trying to understand it! But basically it will shrink the table to fit into the available space (interestingly, it does this even if the width:100% isn't there - I believe this is part of the spec).

    Indeed, if you use your browser's inspector tools on the column headers, you'll see your 300px width has been applied to them.

    If you want 300px width columns, then table-layout: fixed is the way to do that in browsers.

    Allan

  • jungyongwoojungyongwoo Posts: 2Questions: 0Answers: 0

    Although scroll, i need width 300px columns, because that is very important to be represented datas in my page :(

    Please consider additional feature..

    Thanks :D

  • allanallan Posts: 61,934Questions: 1Answers: 10,154 Site admin

    If you know you have 5 * 300px columns, then why set the width to be 100%? Set it to be 1500px.

    This is the behaviour of the web-browser and I don't think it is something that DataTables should attempt to override.

    Allan

This discussion has been closed.