I'm having trouble using jQuery Datatables to sort data.
I have a table that has many columns. The column I want to sort is Document Number. Some document numbers have an A at the start and some don't. I am trying to sort these in descending order without regard to that letter A.
Currently the data looks like this:
A83052 A83030 A83019 A08565 A08554 A08542 A08455 08500 08365 08345 00098 But I want it sorted as follows:
A83052 A83030 A83019 A08565 A08554 A08542 08500 A08455 08365 08345 00098 I do have to leave the A there, however, since it is part of the Document number.
Here is my code:
j$("table[id$=policyBlock]").DataTable({ "order": [[0, 'desc']], "bFilter": false, "bPaginate": false, "bInfo": false }); What I tried to do is add the following after the "bInfo" field:
"columnDefs": [ { "targets": 0, "render": function( data, type, row ) { return type=="sort" ? data.replace(/\D/g,'') : data; } }] The list then ordered itself as so:
00098 08365 08500 A83019 A08565 A83030 A08554 A83052 A08455 08345 A08542 What am I doing wrong?