• Resolved hornof

    (@hornof)


    Hey Tobias – Great plugin! I’m a first-time user working on a fresh installation for a client. After some initial problems (mainly due to bad XLS data) I’m finally getting the hang of it.

    We’re really close. Their last remaining request is to be able to sort the table by a date column which doesn’t contain a “day” value, only month & year.

    Ideally we’d like to present our table sorted as follows:
    Jun 2013
    May 2013
    Apr 2013
    etc.

    or
    6/2013
    5/2013
    4/2013
    would do. We have data that goes back 5 years.

    I’ve searched around to no avail. The closest thread I found was
    https://www.ads-software.com/support/topic/sorting-by-dateformat?
    but can’t quite get that to work. Euro or US date formats aren’t an issue, since we have no day field.

    Thanks for any help you (or anyone else) could give.

    https://www.ads-software.com/plugins/tablepress/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    As this is a custom date format, for which there’s no support built-in into the DataTables JS library (or the existing TablePress Extensions), you’ll basically need to develop a custom JavaScript sorting algorithm for this date format.
    The code in the link that you have already found is a great starting point for that, and should just need minor modifications. You’ll basically need to use that to transform your date format into a plain numerical value that can be compared directly. The code will then give you a new sorting format that you can apply to a certain column by extending the “Custom Commands” on the “Edit” screen of TablePress. That would be done in the same way as the TablePress Extension at https://tablepress.org/extensions/datatables-sorting-plugins/

    Does this help?

    Regards,
    Tobias

    Thread Starter hornof

    (@hornof)

    Thanks – sounds like I’m on the right track. I have a friend who should be able to help me with this. If I can figure out the code, I’ll paste it here.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    great! With the code that you have found, you shouldn’t be too far away from getting this to work. If you need more hints, just let me know!

    Best wishes,
    Tobias

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sort by month/year (no day field)’ is closed to new replies.