更新时间:2023-11-24 21:53:28
使用 createdRow
和 columns.createdCell
选项以定义在创建 TR
和 TD
元素时将调用的回调函数。
Use createdRow
and columns.createdCell
options to define a callback function that will be called when TR
and TD
element are created.
$('#example').dataTable( {
'createdRow': function( row, data, dataIndex ) {
$(row).attr('id', 'someID');
},
'columnDefs': [
{
'targets': 3,
'createdCell': function (td, cellData, rowData, row, col) {
$(td).attr('id', 'otherID');
}
}
]
});
请参见此示例进行代码和演示。
See this example for code and demonstration.