Problem with sorting dates with jquery tablesorter

后端 未结 8 726
终归单人心
终归单人心 2021-02-02 12:18

I am using tablesorter plugin to sort my tables in an MVC .NET App. Most of my columns are strings and I\'m having no problems with them. Neither with the numeric ones. The thin

相关标签:
8条回答
  • 2021-02-02 12:51

    This was the answer for me:

    <td data-order=<fmt:formatDate pattern = "yyyy-MM-dd" value = "${myObject.myDate}" />>${myObject.myDate}</td>
    

    more details, here: https://datatables.net/manual/data/

    0 讨论(0)
  • 2021-02-02 12:55

    Try adding a Tablesorter parser to your date column. Tablesorter comes with a parser for shortDate, usLongDate and isoDate.

    $("#table").tablesorter({
        headers: { colNum: { sorter: 'shortDate'} }
    });
    

    where colNum is the column with the dates. The only example I could find on the tablesorter site is here. This also works if tablesorter is sorting numbers wrong as well. There are other parsers as well for percent, ip address and more. Take a look near the end of the source code and they'll be listed there.

    Edit: In looking at the source code, the dateFormat option appears to be looking only for "us", "uk", "dd/mm/yy" or "dd-mm-yy". What happens when you try "uk"?

    0 讨论(0)
提交回复
热议问题