如何在服务器端处理模式下将 class 添加到 <td>
How to add a class to the <td> in server-side processing mode
在 DataTable 上使用服务器端处理时,有一种机制可以将 ID、class 或 data-*
属性添加到 table 行(<tr>
) 通过将 DT_RowId
、DT_RowClass
或 DT_RowData
属性分别包含到每一行的 JSON 数据中:https://datatables.net/examples/server_side/ids.html.
是否有用于向 table 列 (<td>
) 添加额外标记的类似(或任何)机制?
您可以像这样将 类 添加到列中,但不确定这是否能让您到达您想去的地方:
var all_data = data;
$("#example").DataTable({
"data": all_data,
"aoColumns": [{
"data": 'cat_code',
"className": "lang_body_2",//you can add whatever you want for a specific column here.
"visible": false
}, {
"data": 'value',
"searchable": false,
"width": "20%",
"className": "lang_body_2",
"title": ""
}]
})
其他方式,从关闭。网站 docs。
将 class my_class 分配给第一列
$('#example').dataTable( {
"columnDefs": [
{ className: "my_class", "targets": [ 0 ] }
]
} );
在 DataTable 上使用服务器端处理时,有一种机制可以将 ID、class 或 data-*
属性添加到 table 行(<tr>
) 通过将 DT_RowId
、DT_RowClass
或 DT_RowData
属性分别包含到每一行的 JSON 数据中:https://datatables.net/examples/server_side/ids.html.
是否有用于向 table 列 (<td>
) 添加额外标记的类似(或任何)机制?
您可以像这样将 类 添加到列中,但不确定这是否能让您到达您想去的地方:
var all_data = data;
$("#example").DataTable({
"data": all_data,
"aoColumns": [{
"data": 'cat_code',
"className": "lang_body_2",//you can add whatever you want for a specific column here.
"visible": false
}, {
"data": 'value',
"searchable": false,
"width": "20%",
"className": "lang_body_2",
"title": ""
}]
})
其他方式,从关闭。网站 docs。 将 class my_class 分配给第一列
$('#example').dataTable( {
"columnDefs": [
{ className: "my_class", "targets": [ 0 ] }
]
} );