Adding an ID to TR
Adding an ID to TR
bbrindza
Posts: 316Questions: 73Answers: 1
I found a few examples of adding an ID to a table row, however they do not seem to fit my needs based on my table script.
I tried row.add() but just could not figure out how to do this when using columns:[ ]
childTable = $('#customerRows').DataTable({
dom: 't',
ajax: {
type: 'POST',
url: 'getSalepersonByCustomerBillTo_CustomerData.php',
data: {salespersonNumber: salespersonNumber},
},
pageLength:100,
columns: [
{
className: 'detail-level-control_2',
orderable: false,
data: null,
defaultContent: '',
},
{
data: 'customer'
},
{
data: null,
searchable: false,
orderable: false,
render: function ( data, type, row ) {
if (row.openBudget != 0) {
return '<td><button id="openBudgetButton">Open '+ row.openBudget + '</button></td>';
}else{
return '<td><strong><p style="color:green;">Completed</p></strong></td>';
}
}
},
{
data: null,
searchable: false,
orderable: false,
render: function ( data, type, row ) {
if (row.openBudget != 0) {
return '<td><button id="completedBudgetButton">Completed '+ row.completedBudget + '</button></td>';
}else{
return '<td></td>';
}
}
},
{
data: null,
searchable: false,
orderable: false,
render: function ( data, type, row ) {
if (row.openBudget != 0) {
return '<td><button id="totalBudgetButton">Total '+ row.totalBudget + '</button></td>';
}else{
return '<td></td>';
}
}
},
{ data: 'customerNumber',
visible: false
}
],
columnDefs: [
// { targets: [0], className: 'level-2-control-row-format-0'},
{ targets: [1], className: 'level-2-control-row-format-1' },
{ targets: [2], className: 'level-2-control-row-format-2' },
{ targets: [3], className: 'level-2-control-row-format-3' },
{ targets: [4], className: 'level-2-control-row-format-4' },
],
select: false,
});
This question has an accepted answers - jump to answer
Answers
Try using
rowId
.Kevin
rowId: 'customer',
That did it. Thank you Kevin!