Issue setting a td id/name in DataTables 1.10.x
You need to use createdRow property to define callback for whenever a TR element is created for the table's body.
$('#example').dataTable( {
"createdRow": function ( row, data, index ) {
$('td', row).eq(1).attr('id', 'td-' + index + '-1');
}
});
Code $('td', row).eq(1)
is used to select second cell in the table row using zero-based index (1
for second cell). Code attr('id', 'td-' + index + '-1')
will set that cell id
attribute to td-0-1
for first row, td-1-1
for second row, etc., where index
is zero-based row index.
See this JSFiddle or Row created callback example for demonstration.