Hi everybody,
I use with success Datatables since several months but recently I discover a little but in the sorting plugins "Date (dd/mm/YYY hh:ii:ss) ".
The current code is the following:
I test this code and I've found a little bug at this line : "var x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + frTimea[2]) * 1;"
The frTimea array contains just two elements not 3! So, the sort doesn't work.
The correct code is the following (I've just suppressed "frTimea[2]" and it's work perfectly):
Best regards,
RémiV
I use with success Datatables since several months but recently I discover a little but in the sorting plugins "Date (dd/mm/YYY hh:ii:ss) ".
The current code is the following:
jQuery.extend( jQuery.fn.dataTableExt.oSort, { "date-euro-pre": function ( a ) { if ($.trim(a) != '') { var frDatea = $.trim(a).split(' '); var frTimea = frDatea[1].split(':'); var frDatea2 = frDatea[0].split('/'); var x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + frTimea[2]) * 1; } else { var x = 10000000000000; // = l'an 1000 ... } return x; }, "date-euro-asc": function ( a, b ) { return a - b; }, "date-euro-desc": function ( a, b ) { return b - a; } } );
I test this code and I've found a little bug at this line : "var x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + frTimea[2]) * 1;"
The frTimea array contains just two elements not 3! So, the sort doesn't work.
The correct code is the following (I've just suppressed "frTimea[2]" and it's work perfectly):
jQuery.extend( jQuery.fn.dataTableExt.oSort, { "date-euro-pre": function ( a ) { if ($.trim(a) != '') { var frDatea = $.trim(a).split(' '); var frTimea = frDatea[1].split(':'); var frDatea2 = frDatea[0].split('/'); var x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1]) * 1; } else { var x = 10000000000000; // = l'an 1000 ... } return x; }, "date-euro-asc": function ( a, b ) { return a - b; }, "date-euro-desc": function ( a, b ) { return b - a; } } );
Best regards,
RémiV