• Resolved cberendes

    (@cberendes)


    In brief: what columndefs – type to use to get the most flexible (for a USA audience) datetime parsing and sorting, and what formats would be accepted?

    Details:

    Ideally, I’d like these dates to sort in the right order: December 24, March 24 10:45 AM, “April 4 6:30-8pm”, January 15 10:00 AM, “April 6 9-10:30 am”

    If that’s not possible, I’d hope to enable RFC 2822 sorting, so that these dates sort correctly: Wed, 02 Oct 2002 10:00:00 EST, Wed, 02 Oct 2002 08:00:00 EST, Mon, 30 Sep 2002 10:00:00 EST, Thu, 03 Oct 2002 10:00:00 EST, Fri, 04 Oct 2002 10:00:00 EST

    I have TablePress Extension: Sorting plugins installed and activated.

    Custom commands: “columnDefs”: [ { “type”: “luxon”, “targets”: [ 1,2,3 ] } ], “order”: [ [ 2, “desc” ] ]

    Also tried with datetime-luxon, to no avail. All I get is alpha-order, e.g. Fri then Thu then Wed, independent of calendar dates.

    Goal is for non-techie volunteers to be able to enter dates/times and to have those dates/times display in a friendly way, to a USA-based audience. RFC 2822 is a bit “computer-y” for them, but we could live with it.

    P.S. I’m still in my first 24 h of testing w/Tablepress – it’s amazing and wonderful and will help our volunteers tremendously – Thank you.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter cberendes

    (@cberendes)

    I noticed a previous support request for https://www.savethepostoffice.com/document-table/. Their m/dd/yyyy Date column would work for us.

    Page source suggests that this was achieved via type -> “date” in columnDefs, but I can’t get that to work on my site. (And of course I can’t tell what plugins savethepostoffice.com has loaded…)

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi!

    Thanks for your post and sorry for the trouble!

    The mm/dd/yyyy format (unless extended with other data, like times or even text) will actually recognized by default, without needing a “Custom Command”. So, using that might be the easiest.

    If you would like to use a more complex format (for which there are no directly usable sorting algorithms implemented at this time), I would actually recommend the approach from https://www.ads-software.com/support/topic/date-order-6/

    Regards,
    Tobias

    Thread Starter cberendes

    (@cberendes)

    Thanks.

    I tried it here: https://stmstage.netalyst.com/test-sort/

    Alas, 10/15/2023 should be before 10/01/2024, but isn’t.

    (Also: https://www.savethepostoffice.com/document-table/ seems to work with d/m/yyyy , which is a little friendlier…)

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    ah, on that page, the sorting is not working because (technically), the cell with “10/01/2024” does not contain a pure date — it also has an extra line break after that date, which changes the cell format from “date” to “string”. Can you please try again after removing the line break after that date?

    For sorting the other date format, using the TablePress Extension from https://tablepress.org/extensions/datatables-sorting-plugins/ will indeed work. Just use the value date-eu for the type property in the “Custom Command”.

    Regards,
    Tobias

    Thread Starter cberendes

    (@cberendes)

    Thanks. That fixed it.

    Is there some way to diagnose or trace how Tablepress/Datatables are parsing a column to be sorted? E.g. what could I have looked at to see that extra line break or the trouble it was causing?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    that’s good to hear! Debugging this is a bit tricky, and a lot of it probably comes with experience. But pretty much always when the sorting appears wrong it’s something with the data types being wrong.

    Now, you could maybe take a look at https://debug.datatables.net/ which offers a JavaScript bookmarklet that offers for insights into the table configuration, including for example the detected data types for the columns.

    Regards,
    Tobias

    Thread Starter cberendes

    (@cberendes)

    Interesting. Thanks.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘columndefs for RFC 2822 (or ideally most flexible) date sort?’ is closed to new replies.