WordPress.org

Ready to get started?Download WordPress

Forums

TablePress
[resolved] Sort by Date troubles... (8 posts)

  1. David Jamieson
    Member
    Posted 1 year ago #

    Hi Tobias,

    Love your plugin. It's been very useful, and I was happy to donate. I do have a problem, however, with sorting by date. I've changed the dates in the column I wish to sort by in EU format, and added the following code to the Custom Commands section:

    "aoColumnDefs": [ { "asSorting": [ "desc" ], "aTargets": [ 4 ] } ]

    I also have installed the Datatables Sorting Plugin, but the dates don't appear to be recognized. What am I missing?

    http://test.vitruvianstudio.com/art-classes-chicago/all-classes/

    http://wordpress.org/extend/plugins/tablepress/

  2. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    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

  3. David Jamieson
    Member
    Posted 1 year ago #

    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: http://test.vitruvianstudio.com/art-classes-chicago/all-classes/

    Sorry to be so obtuse!

    David.

  4. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    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

  5. David Jamieson
    Member
    Posted 1 year ago #

    Great, Tobias, that seems to have done the trick :D

    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)

  6. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    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

  7. David Jamieson
    Member
    Posted 1 year ago #

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

  8. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic