admin管理员组文章数量:1327660
When using server-side processing on a DataTable, there is a mechanism to add an ID, class, or data-*
attribute to the table row (<tr>
) by including the DT_RowId
, DT_RowClass
or DT_RowData
properties, respectively, to the JSON data for each row: .html.
Is there a similar (or any) mechanism for adding additional markup to the table columns (<td>
)?
When using server-side processing on a DataTable, there is a mechanism to add an ID, class, or data-*
attribute to the table row (<tr>
) by including the DT_RowId
, DT_RowClass
or DT_RowData
properties, respectively, to the JSON data for each row: https://datatables/examples/server_side/ids.html.
Is there a similar (or any) mechanism for adding additional markup to the table columns (<td>
)?
2 Answers
Reset to default 3You can add classes to columns like so, but not sure if this gets you where you want to go:
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": ""
}]
})
Other way, from off. sites docs. Assign class my_class to first column
$('#example').dataTable( {
"columnDefs": [
{ className: "my_class", "targets": [ 0 ] }
]
} );
本文标签: javascriptHow to add a class to the lttdgt in serverside processing modeStack Overflow
版权声明:本文标题:javascript - How to add a class to the <td> in server-side processing mode - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742227283a2436558.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论