Responsive table with set columns widths for first few columns

Responsive table with set columns widths for first few columns

tonykotonyko Posts: 13Questions: 7Answers: 0

I'm using responsive datatables v1.10, is it possible to set fixed column widths for a few of the columns while using the responsive mode? Any help would be greatly appreciated.

I've been trying to set the width of the columns, but it won't take it when I initialized datatables columndef with columnwidths. When I hardcode the actual <th> element with the width in pixels, it breaks the responsiveness of the table.

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    edited October 2020

    You could try setting the width with columns.width, that may do the trick,

    Colin

  • json81json81 Posts: 24Questions: 6Answers: 1

    Hi!
    In column definition, add a className:

                   "columns": [
                        {
                            "data": "mycolumn,
                    "className": 'fixed_width',
                        },
    

    Use CSS to add a width of your choice to one or many columns:

        table.dataTable td.fixed_width {
            width:10px;
        }
    

    /Anders

This discussion has been closed.