如果值太长,我的数据表的列看起来会更宽。
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 }
]
但是我的数据表没有变化。
最佳答案
我会这样做
table.dataTable tbody td {
word-break: break-word;
vertical-align: top;
}
演示 -> http://jsfiddle.net/qh63k1sg/
这意味着 autoWidth
设置为 false 并且您已为列指定了固定宽度(如演示中和 OP 描述的那样,他使用 aoColumns
/列
).
关于php - jquery 数据表自动换行不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37939056/