Hello,
I'm facing a problem with custom sorting datas
My test page is available here http://www.strangeplanet.fr/files/movies.htm
For "Name" and "Filesize" collumns I added a "data-value" attribute with different data than displayed :
for filesizes I use the complete value in bytes and for names I "overwrite" articles ("The Aviator" becomes "A. The Aviator") in order to have kind of natural sorting
then I use this SortDataType (adapted from the doc)
my problem is that... it doesn't work ! the initial sorting on "Name" collumn is good, but if I change it, things are messed up (names begining with a figure are not at the begining of the table). it's way more visible on the "Filesize" collumn, first time you have a nice order from 384 Mio to 20Gio and then..... nothing
what am I doing wrong ?
Thanks
I'm facing a problem with custom sorting datas
My test page is available here http://www.strangeplanet.fr/files/movies.htm
For "Name" and "Filesize" collumns I added a "data-value" attribute with different data than displayed :
for filesizes I use the complete value in bytes and for names I "overwrite" articles ("The Aviator" becomes "A. The Aviator") in order to have kind of natural sorting
then I use this SortDataType (adapted from the doc)
jQuery.extend( jQuery.fn.dataTableExt.afnSortData, { 'data-value': function ( oSettings, iColumn ) { var aData = []; $( 'td:eq('+iColumn+')', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () { aData.push( $(this).data('value') ); } ); return aData; } }); var oTable = $('#list').dataTable({ "bJQueryUI": true, "aaSorting": [ [0,'asc'] ], "aoColumns": [ { "sSortDataType": "data-value", "sType": "natural" }, { "sType": "720-1080" }, null, { "sSortDataType": "data-value", "sType": "numeric" }, { "sType": "date-uk" } ] });
my problem is that... it doesn't work ! the initial sorting on "Name" collumn is good, but if I change it, things are messed up (names begining with a figure are not at the begining of the table). it's way more visible on the "Filesize" collumn, first time you have a nice order from 384 Mio to 20Gio and then..... nothing
what am I doing wrong ?
Thanks