Date sorting problems

Date sorting problems

grtgrt1grtgrt1 Posts: 2Questions: 0Answers: 0
edited September 2012 in Plug-ins
Hello,

My date is structured (d)d. (m)m. yyyy - for example 1. 12. 2000, 12. 3. 2000, 12. 12. 1999 etc.

Using the Date (dd . mm[ . YYYY]) plugin and sType="eu_date" renders my table unsortable, and it overrides the rows per page display and css as well. In other words, I get absolutely no success. I do not know what I am doing wrong.

Using the Date (dd/mm/YY) with a changed split, leaves the table intact, but seems to separately sort the d/m/yyyy dates from the dd/mm/yyyy ones.

Where in here should I add the code to make datatables understand for example "1" as "01" (my guess is this would solve the issue)?

jQuery.fn.dataTableExt.oSort['uk_date-asc'] = function(a,b) {
var ukDatea = a.split('. ');
var ukDateb = b.split('. ');

var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;

return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};

jQuery.fn.dataTableExt.oSort['uk_date-desc'] = function(a,b) {
var ukDatea = a.split('. ');
var ukDateb = b.split('. ');

var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;

return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};

Here's the debug data: http://debug.datatables.net/avihut

Thanks in advance!

Replies

  • grtgrt1grtgrt1 Posts: 2Questions: 0Answers: 0
    I've solved my problem, this can be closed.

    The Date (dd . mm[ . YYYY]) plugin works just fine, but it's sType="date-eu", stupid me.
This discussion has been closed.