Datatables 1.10 - HTML5 "data-order" attr takes no effect.

Datatables 1.10 - HTML5 "data-order" attr takes no effect.

MarcellisMarcellis Posts: 1Questions: 1Answers: 0
edited June 2014 in Free community support

Hi!
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.

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();
                },

But this makes no difference to the ordering of the table. Any guesses?

This discussion has been closed.