How to show less text in each column?
How to show less text in each column?
mdev
Posts: 3Questions: 1Answers: 0
Some columns contain very long sentences, So the table exceeds the browser width and a horizontal scroll bar is shown.
Is there is an option to reduce the text and show only few words?
Or a read more option?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Here is how I do it: ( I set the second column excessively small for illustration).
http://live.datatables.net/duhumilo/1/edit
I use the createdRow callback to set the title so the user can mouse over and see full text.
My css:
and JavaScript:
Hi @mdev ,
In addition to @bindrid 's suggestion, this blog post here may be useful,
Cheers,
Colin
@bindrid , What if I want to apply that for more that one column?
targets:[1, 2,4]
?I changed it to :
columnDefs:[{targets:[1, 2, 4],className:"truncate"}],
createdRow: function(row){
var td = jQuery(row).find(".truncate");
td.each(function(index, el) {
jQuery(this).attr("title", jQuery(this).html());
});
}
or