force width for one column but letting others autosize to content & screen

force width for one column but letting others autosize to content & screen

trucmuche2005trucmuche2005 Posts: 71Questions: 22Answers: 2

Hello,

In the first column, i have 'details-control' like in this demo page. I would like to force this column width to 25px and not more, but I tried for days many combinations of "autoWidth" : true / false, "responsive": true/false, "columns": [{"className": 'details-control w25px', ...}] where
.w25px{ width:25px; min-width:25px; max-width:25px;}
without success. The size is never modified and I cannot understand why.

I'm using DataTables inside an AdminLTE environment and the table has classes :

<

table id="table2" class="table table-bordered table-striped">

Could you help me setting a small width to this row ?

Many thanks,

T.

Answers

  • NineForty5NineForty5 Posts: 9Questions: 0Answers: 2
    edited October 2016

    You need to use the columnDefs parameter to set the width.

    'columnDefs': [
           { "width": "25px", "targets": [0] },
           { "bSortable": false, "targets": [0] }
       ]
    

    You can see an example here

  • trucmuche2005trucmuche2005 Posts: 71Questions: 22Answers: 2

    It does not work either : the width of the column is increased when I change the browser width... I put "autoWidth": false and "responsive": false too, and it does not work... The width of the cell is not fixed to 25px...

This discussion has been closed.