UK date sorting does not work when date is also a link

UK date sorting does not work when date is also a link

mrseefeldmrseefeld Posts: 5Questions: 0Answers: 0
edited March 2012 in General
Great plugin Allan, well done!

I notices that UK date sorting does not work when a date is also a link.

Example 1. (http://dl.dropbox.com/u/17683975/blog/DataTables%20-%20Sort%20by%20UK%20Date%20-%20without%20HREF/index.html)

Here the date is pure test. Works complete fine.

[code]

01/01/01
Tarik
Rashad Kidd
1 34 238 6239-0509


11/02/01
Dominic
Joel Nolan
1 30 147 5889-3252


13/02/01
Abdul
Arsenio Jordan
1 42 828 1680-1804

[/code]

Example 2. (http://dl.dropbox.com/u/17683975/blog/DataTables%20-%20Sort%20by%20UK%20Date%20-%20with%20HREF/index.html)

Here the date is also a link. Does not work at all. Not throwing any errors though.

[code]

01/01/01
Tarik
Rashad Kidd
1 34 238 6239-0509


11/02/01
Dominic
Joel Nolan
1 30 147 5889-3252


13/02/01
Abdul
Arsenio Jordan
1 42 828 1680-1804

[/code]

I also noticed that sorting on any other elements even if they are a link. Only the date as a link are the issue.

I'm using the following JS code:

[code]
// UK Date Sorting
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));
}


$(document).ready(function() {

$('#table').dataTable( {
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"aoColumnDefs" : [
{ "aTargets" : ["uk-date-column"] , "sType" : "uk_date"}
]
});

});
[/code]



Any help much appreciated.
This discussion has been closed.