Sorting not working correctly when adding data-order through createdCell
Sorting not working correctly when adding data-order through createdCell
kulkarni_ash
Posts: 35Questions: 8Answers: 0
Hi
I am working on creating datatable dynamically, i am changing how data displays using rendere and then using createdCell to add data-order, but looks like ordering is not working as expected, i also have bDeferRender set to true.
Here is the code
var table = $(tableId).DataTable(
{
"destroy": true,
"responsive": true,
"bProcessing": true,
"bDeferRender": true,
"paging": true,
"aaData": tableData,
"aoColumns": tableHeader,
"columnDefs": [
{
"createdCell": function (td, cellData, rowData, row, col) {
$(td).attr("data-order", cellData);
},
"render": function ( data, type, row ) {
if(data > -1){
return data.format(0,3,',','.');
}
else{
return "<span style=\"color:red\">( " + Math.abs(data).format(0,3,',','.') + " )</span>";
}
},
"targets": 5
}
]
This discussion has been closed.
Answers
This is how i solved this problem,
I removed the render and moved that logic to createdCell