nunu nunu - 5 months ago 28
SQL Question

jquery datatables word wrap not working

My datatable's column looks wider if the value is too long.

enter image description here

i have following this and this.
And setting the width :

aTable = $("#printdata").dataTable({
"bAutoWidth" : false,
"bRetrieve" : true,
"scrollY": 200,
"scrollX": true,
"deferRender": true,
"scroller": {
loadingIndicator: true
},
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": 'show2ndsampling.php',
"fnServerData": function (sSource,aoData,fnCallback){
$.ajax({
"dataType":'json',
"type":'POST',
"url":sSource,
"data":aoData,
"success":function(json){
fnCallback(json);
}
});
},
"order" : [[1,"desc"]],
"aoColumns" : [
/*serial*/{ "width": "30%", target : 3 }
]


But there is no change in my datatable.

Answer

I would do this

table.dataTable tbody td {
  word-break: break-word;
  vertical-align: top;
}

demo -> http://jsfiddle.net/qh63k1sg/

This is implied that autoWidth is set to false and you have given the columns a fixed width (as in the demo and as OP have described he does with aoColumns / columns).