I'm having trouble ordering a column which has HTML in it. It is stated in the documentation for 1.10 that this should be taken care of by default, but It doesn't. Then I looked into the new features of 1.10 and saw that if there was a "data-order" attribute for each TD element in the same column, ordering could be done by said attributes. Perfect! Problem is, I can't get it to work.
Strange thing is that the example they have of this when the page is static is working as intended, but not when the data and the table is loaded dynamically.
I'm initiating the table with the following options and alterations to add the attributes. The invalidation is done to tell Datatables that it needs to redraw it (I saw it was needed somewhere):
"createdRow": function ( row, data, index ) {
if ( data[6] ) {
cell = $('td', row).eq(6);
value = cell.text();
if(value == "Ej fakturerad") {
cell.attr('data-order', 1);
}
else if(value == "Nej") {
cell.attr('data-order', 2);
}
else if(value == "Kredit") {
cell.attr('data-order', 3);
}
else if(value == "Ja") {
cell.attr('data-order', 4);
}
}
oTable
.row( index )
.invalidate()
.draw();
},
I'm implementing this DataTable with a composer package from Chumper/datatables in a Laravel project, which means the data source is Ajax, and uses server side processing.
Thanks in advance!