How to add data-order attribute when building data tables dynamically
How to add data-order attribute when building data tables dynamically

Hi
How to add data-order attribute or some other HTML5 attributes when building table dynamically
This is what i am have so far, i want to add data-order to 6th column, since i am converting this numeric value to text.
var table = $(tableId).DataTable(
{
"destroy": true,
"responsive": true,
"bProcessing": true,
"bDeferRender": true,
"paging": true,
"aaData": tableData,
"aoColumns": tableHeader,
"columnDefs": [
{
"render": function ( data, type, row ) {
if(data > -1){
return data.format(2,3,',','.');
}
else{
return "<span style=\"color:red\">( " + Math.abs(data).format(2,3,',','.') + " )</span>";
}
},
"targets": 6
}
],
}
);
This discussion has been closed.
Answers
This is where i have the solution, use createCell
https://datatables.net/forums/discussion/38387/sorting-not-working-correctly-when-adding-data-order-through-createdcell#latest