Maximum column width for all columns
Maximum column width for all columns
How can I set a maximum width for all columns?
The table is generated dynamically, I can´t tell with column has too much content. Currently, a column with many characters takes up so much space that the table has to be scrolled in x-direction. If the max width is exceeded, there should be a line break.
I tried, with no visible effect:
var columnDefs = [
{
width: '50px',
targets: '_all'
}
];
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Normally you can't directly - that isn't how HTML tables work. However, there are two options:
table-layout: fixedwill give you pixel perfect control over the table column widths using thetable-layoutCSS property. The downside is that the table doesn't adjust for mistakes and often content will overflow.div(which you could do with a rendering function) and apply themax-widthto that.Allan
I chose the second option: