Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery table sorter - dd/mm/yyyy parser

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
     },
    }});
}); 
like image 976
Motley9735 Avatar asked Dec 13 '22 14:12

Motley9735


1 Answers

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 :-)

like image 176
Guidhouse Avatar answered Feb 15 '23 10:02

Guidhouse