Column width option not being applied
Column width option not being applied
andrewtmendoza
Posts: 12Questions: 4Answers: 0
I'm trying to apply a column width to each column, but it is not being reflected in the output:
http://live.datatables.net/mekuxeya/1/edit?js,output
I've tried setting autoWidth to both true and false, but it does not seem to have any effect. Bootstrap styling, scrollX, and scrollY are also being applied.
This discussion has been closed.
Answers
You can set with in you table header
<th width="20%"></th>
and you must remove columnDefs option
@mackmack - I tried that, but it didn't work on the live example I shared.
@allan - is there a certain width that individual columns are limited to?
Thanks,
Andrew
Ok, I think I figured it out. In the HTML, I had to remove the width="100%" attribute from the table tag. In the JavaScript, I had to leave the autoWidth option as true.
http://live.datatables.net/huxuqejo/1/edit
@allan, isn't the autoWidth option supposed to be false if you are specifying the column widths yourself?
https://datatables.net/reference/option/autoWidth
Thanks,
Andrew
I have run into the same problem with the same solution, and have the same reservations about the contradictory behavior of autoWidth.
@allan : do you have any comment on @andrew 's last post?
If his solution is correct, it seems rather counter-intuitive. I know table column widths generally can be tricky, and a definitive DT answer would be very helpful although I suspect "definitive" is too strong a word .