Support » Plugin: TablePress » Sorting a column by a dd/mm/yyyy date format

  • Resolved andyknapp

    (@andyknapp)


    Hi,

    TablePress is a great plugin – was so easy to set up this page but I’m having trouble sorting the data column which is in the UK format dd/mm/yyyy. I’ve followed the instructions from a previous post and inserted:

    “columnDefs”: [ { “type”: “date”, “targets”: [ 2 ] } ]

    into the Custom commands

    also tried:

    “columnDefs”: [ { “type”: “date-eu-pre”, “targets”: [ 2 ] } ]

    I’ve used moment.js at work on a Spring Boot project but the postings on TablePress seem to indicate this should not be necessary.

    – I’d be grateful for any help on this!

    Andy

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

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

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    Can you please try

    "columnDefs": [ { "type": "date-eu", "targets": [ 2 ] } ]
    

    ?

    Regards,
    Tobias

    Thread Starter andyknapp

    (@andyknapp)

    Thanks Tobias,

    That was such a quick response and it worked!! I just didn’t expect the UK to be aligned with the EU!! 😉

    Many Thanks

    Andy

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

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

    Best wishes,
    Tobias

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

    Hello.
    I tried to do the same (I put “columnDefs”: [ { “type”: “date-eu”, “targets”: [ 2 ] } ]) for the page http://www.dkammenos.gr/petitions/ for the date (dd/mm/yyyy) and I failed.
    Any idea?

    Thanks i advance,
    Antonis
    Athens GREECE

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Antonis,

    for this to work, you will also need to install the TablePress Extension from https://tablepress.org/extensions/datatables-sorting-plugins/

    Regards,
    Tobias

    Hello Tobias.
    Thank you for the reply.
    The plugin has been already succesfully installed (before my post).
    The result is NO sorting at all.
    The only issue may be is that the the WP version is 4.2.2 and not 4.8.1
    If I will update the WP version, could be resolved?
    Do you have any other idea?

    Thank you in advance,
    Antonis

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    you should definitely update WordPress and all plugins, yes! This might even fix the issue, as you will get a newer version of TablePress, which might not even need the Extension.
    If the problem still persists after updating, please post a link to the page with the table, so that I can take a direct look.

    Regards,
    Tobias

    Look for example in this page:
    http://www.dkammenos.gr/activities/
    It sorts perfect column 2 and column 3 and it presents date (1st column) sorted (ascending).
    But the control for descending sorting of date dosen’t work.
    Any idea?

    PS
    The command that has been given in this table is:
    “columnDefs”: [ { “type”: “date-eu”, “targets”: [ 0] } ]

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    strange… But as I said, please update everything. You will then get TablePress 1.8 which might not even need the Extension anymore.

    Regards,
    Tobias

    Hi Tobias,

    I am having a strange problem. I have added custom code “columnDefs”: [ { “type”: “date-eu”, “targets”: [ 2 ] } ] to sort dates in 3rd column in dd/mm/yyyy format, and it is working except for the bottom 4 rows of the table, which simply stay in place at the bottom of the table? Thanks,

    Regards
    Tully

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    bendidog: Can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!

    Regards,
    Tobias

    Hi Tobias,

    It is on a member only password protected page, can I send the link to you privately?

    Thanks, Tully

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    sure, my email is in the main plugin file “tablepress.php”.

    Regards,
    Tobias

    Hi Tobias,

    We are trying to sort our data which is based on the dd.mm.yyyy format also, and have tried adding the
    “columnDefs”: [ { “type”: “date-eu”, “targets”: [ 6,7 ] } ]
    But it is still not sorting correctly.

    Our dates are written as dd.mm.yyyy instead of dd/mm/yyyy

    Should the code also work for date separator with periods?

    Page of the content is on https://icoreview.site/tablepress-test2/

    Thank you very much for your help in this matter.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    Yes, the code should also work with periods.
    Note that you should change the 6 and 7 to

    "columnDefs": [ { "type": "date-eu", "targets": [ 5,6 ] } ]
    

    because counting the columns starts with 0.

    In addition, it seems like you will have to add a date to all rows, as the empty cell in that column seem to cause problems.

    Regards,
    Tobias

Viewing 15 replies - 1 through 15 (of 33 total)
  • The topic ‘Sorting a column by a dd/mm/yyyy date format’ is closed to new replies.