Problem with columDefs
Problem with columDefs
JochenK
Posts: 55Questions: 10Answers: 0
Link to test case:
https://live.datatables.net/sasumidi/1/edit
Description of problem:
I want to set the 2nd column ("Thema") in my datatable to 20%.
I use columnDefs for this, but it doesn't seem to work. What can I do ?
This question has an accepted answers - jump to answer
Answers
20% width? You might want to do that, and DataTables is applying that, but the content doesn't allow it to be 20% width. You have:
and since it is a long string, it is correctly showing as a very wide cell.
You could allow the text to wrap, or you could could consider doing something like the ellipsis renderer.
Allan
20% was an example. The 2nd column can contain very long text. Therefore, the column should have a maximum width and the text should wrap into several lines.
The text can be limited with "the ellispsis renderer" and the column width can also be set automatically. However, then I can only set a filter in the search field for the text displayed, in the truncated text is not filtered.
I solved the problem with a div in the td.
the td : { white-space: normal !important; }
the div: { width: 300px; } - px is selectable
https://live.datatables.net/bifomimo/1/edit
That is not true. As documented at the link Allan posted use Orthogonal data to render the ellipsis for only the
display
operation. Here is your test case with an ellipsis renderer. You can search for hidden text, likeM13
, and see the row is still displayed.https://live.datatables.net/sasumidi/3/edit
Kevin
Yes you are right.
I didn't set datatable.reender initially. That was my mistake.
Now it works like it should,
thank you