目前,我一直在手工构建我的表,下面是我的示例代码。
echo"<tr>";
echo"<td style='width: 10%;word-wrap: break-word;'>$count</td>";
echo"<td style='width: 25%;word-wrap: break-word;' class='center'>{$uName}</td>";
echo"<td style='width: 25%;word-wrap: break-word;' class='center'>{$ufName}</td>";
echo"</tr>";现在,我已经进入了datatable,并按下面的方式进行调用。
$('#activeUserGrid').dataTable({
"order": [[ 1, "asc" ]],
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0, 2 ] }],
"aoColumns": [ { sClass: "alignRight" } ],
"processing": true,
"serverSide": true,
"ajax": "getUser.php"
});现在的问题是,我想把每一行的样式都写成。
width: 25%;word-wrap: break-word;这个式样在哪里分配?
发布于 2016-07-10 01:59:53
您需要属性className of columnDefs。还可以使用targets指定要应用类的列。就像这样:
$('#table').dataTable( {
"columnDefs": [
{ className: "my-class-1", "targets": [ 0, 1 ] }
{ className: "my-class-2", "targets": [ 2, 3 ] }
]
});此示例对于新的1.10表示法有效。对于遗留(pre1.10) className = sClass,target = aTarget
更多细节:https://datatables.net/reference/option/columns.className
https://stackoverflow.com/questions/38281105
复制相似问题