jquery table sorter - dd/mm/yyyy parser

Motley9735 picture Motley9735 · Apr 13, 2011 · Viewed 8.6k times · Source

After searching around, I can't seem to be able to make the first column sort by the UK date format - dd/mm/yyyy Would anyone be willing to help me with this problem? Current js is:

$(document).ready(function() 
{ 
    $("table.tablecontainer").tablesorter({widgets: ['zebra']});

    $("#myTable").tablesorter({ 
               sortList: [[0,0]], 
       headers: {
           5:{
              sorter: false
           }
       }
    });
}); 

All help appreciated as this isn't an area I can class myself as proficient in at all!

Updated code:

$(document).ready(function() 
{ 
    $("#myTable").tablesorter({widgets: ['zebra']});
    $("#myTable").tableSorter( {dateFormat: "uk"} );
    $("#myTable").tablesorter({ 
    sortList: [[0,0]], 
    headers: {
    // assign the sixth column (we start counting zero)
     5:{
     // this is header 6 since the headers start at 0
        // disable it by setting the property sorter to false
     sorter: false
     },
    }});
}); 

Answer

Guidhouse picture Guidhouse · Apr 14, 2011

I personally use the Jquery tablesorter script from tablesorter.com with the dateFormat- property set to "uk".

    $("#myTable").tablesorter({ 
        widgets: ['zebra'],
        dateFormat: "uk",
        sortList: [[0, 0]], 
        headers: { 5: { sorter: false}} 
     });

You are calling the script several times with different options, which confuses the poor library.

Only make one call to tablesorter with all the different options set as above.

I haven't checked the zebra widget, but the rest behaves as it should now.

Good luck with your endeavor :-)