Column Filtering and adjusting column Width

Column Filtering and adjusting column Width

timcadieuxtimcadieux Posts: 76Questions: 22Answers: 0
edited August 2017 in Free community support

I'm attempting to adjust the width of my columns but no matter what I do, the columns seem to adjust to fit the content inside them.

If I remove all table layout html and just use the below, then the resizing works but I lose the column filtering. If I use the thead and tfoot, then the sizing seems to not work

<table class="table table-bordered table-hover dt-responsive" id="datatable">
</table>

I've purchased the Picollo Support credits but I dont seem to have any new options?

Any help would be appreciated..codepen below

https://codepen.io/anon/pen/rzMGpp

Replies

  • HPBHPB Posts: 73Questions: 2Answers: 18
    edited August 2017

    In the test case you linked it is the inputs that take up the space.
    I have been working around this by applying a 100% width style to the filter inputs.

    Line 4:
    $(this).html( '<input type="text" placeholder="Search" style="width: 100%" />' );

    You will still get your columns adjusted by the content, because setting width in percentages and applying nowrap to the cells doesn't work together.
    I would recommend to either remove the autoWidth attribute, or to remove the nowrap style for td's,

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    "Piccolo" is a supporter donation. If you are looking for paid support, the options are here:
    https://datatables.net/support/index

  • timcadieuxtimcadieux Posts: 76Questions: 22Answers: 0

    Changing this worked for me

    $(this).html( '<input type="text" placeholder="Search" style="width: 100%" />' );
    
This discussion has been closed.