Column wrapping
Column wrapping
johnuga
Posts: 16Questions: 7Answers: 0
I have a table with 12 columns. The last column is a text field usually containing one or two sentences. On the screen, the column wraps so that only about 2 or 3 words appear on one line before it wraps. How can I fix this?
Thanks,
-John
This discussion has been closed.
Answers
Add this to the style of your td
overflow: hidden;
text-overflow: ellipsis;
this would show your test like "abc..."
More on than you can add the actual text in as title of the field , so the actual value will appear on mouse over.
Below is the code you can use to add title for all the values, you can change it to add title for just one column.
$('#table tbody td').each(function(index){
$this = $(this);
var titleVal = $this.text();
if (titleVal != '') {
$this.attr('title', titleVal);
}
});
Let me know if that helps.
Use to add what @Mandeepsg3 says - DataTables 1.10.1's stylesheet will include a
no-wrap
option you can add as a class to your DataTable which will usetd, th { white-space: nowrap; }
which will force all text content on a single line. Until then, you can add that to your own CSS.Allan