Column width option not being applied

Column width option not being applied

andrewtmendozaandrewtmendoza 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.

https://datatables.net/reference/option/columns.width

Answers

  • mackmackmackmack Posts: 15Questions: 1Answers: 2

    You can set with in you table header
    <th width="20%"></th>
    and you must remove columnDefs option

  • andrewtmendozaandrewtmendoza Posts: 12Questions: 4Answers: 0
    edited January 2017

    @mackmack - I tried that, but it didn't work on the live example I shared.

  • andrewtmendozaandrewtmendoza Posts: 12Questions: 4Answers: 0

    @allan - is there a certain width that individual columns are limited to?

    Thanks,
    Andrew

  • andrewtmendozaandrewtmendoza Posts: 12Questions: 4Answers: 0

    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

  • BROB201BROB201 Posts: 28Questions: 4Answers: 0

    I have run into the same problem with the same solution, and have the same reservations about the contradictory behavior of autoWidth.

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394
    edited March 2017

    @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 :smile: .

This discussion has been closed.