Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi David,

    thanks for your post, and sorry for the trouble.

    You basically just need to tell the DataTables library that that column uses EU dates, as the automatic detection is not always working. For that, please try this “Custom Command”:

    "aoColumnDefs": [ { "sType": "date-eu", "aTargets": [ 4 ] } ]

    The “Custom Command” that you posted will only influence the sorting in that regard, that it will only allow descending sorting, but no ascending sorting. Are you sure that you want that?

    Regards,
    Tobias

    Thread Starter David Jamieson

    (@dallenj)

    Hi Tobia,

    Thanks for responding so quickly. Basically, I want the “start date” column on my site to sort with earliest dates first, followed by later dates. Is that ascending or descending?

    I replaced the Custom Command with the one above, but there doesn’t seem to be any change: https://test.vitruvianstudio.com/art-classes-chicago/all-classes/

    Sorry to be so obtuse!

    David.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi David,

    yes, but you want that sort as the initial sort order, and you do not want to prohibit the sorting of that column for the user, right?
    For that, please try this “Custom Command”:

    "aoColumnDefs": [ { "sType": "date-eu", "aTargets": [ 4 ] } ], "aaSorting": [[4,'asc']]

    Now, the actual sorting is broken, because you seem to have modified the JS file of the Sorting Plugins Extension, and due to that it contains a JS error. Could you please try again after replacing the Sorting Plugins Extension with a fresh download?

    Regards,
    Tobias

    Thread Starter David Jamieson

    (@dallenj)

    Great, Tobias, that seems to have done the trick ??

    One other question… The EU date format is actually minor problem since most of my customers are from North America. Is there a way to change the date format to mm/dd/yyyy instead of dd/mm/yyyy? Or even better, is there a way to translate the date to month names instead of numbers? (ie: 01/23/2012 to January 23, 2012)

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    great to hear that this is working! ??

    Yes, mm/dd/yyyy is actually the default date format that is used. That will even work without the extra Sorting Plugins Extensions.

    Just change all dates in that column the that format and simplify the “Custom Commands” to

    "aaSorting": [[4,'asc']]

    I don’t have readily usable code for the “January 23, 2012” format, unfortunately. The code that you had added to the Sorting Plugins Extension could be a good start though. I’d suggest to go with mm/dd/yyyy as a starting point though.

    Regards,
    Tobias

    Thread Starter David Jamieson

    (@dallenj)

    Thanks, Tobias. I appreciate the help! I’ll buy you another coffee!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi David,

    no problem, you are very welcome!

    And thanks for that second donation, I really appreciate it!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Sort by Date troubles…’ is closed to new replies.