Maximum column width for all columns
Maximum column width for all columns
ludwigm
Posts: 12Questions: 8Answers: 1
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
Answers
Normally you can't directly - that isn't how HTML tables work. However, there are two options:
table-layout: fixed
will give you pixel perfect control over the table column widths using thetable-layout
CSS 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-width
to that.Allan
I chose the second option: