JQuery Datatable: Fit column width to content

datatables, jquery

Solution

You can use `autoWidth: true` along with `columns.adjust()` API method to adjust column width after you done adding data to the table.

Problem

I am building a DataTable on the fly, so I don't know the column content upfront. I would like to obtain a table for which each column width fits its content width. I tried to manipulate "autoWidth", but it resizes columns according to their number and to the table width, but all columns have the same width. How can I let each column adjust its width according to its own content?

Original source