Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    That Extension is unrelated to the sorting that the user performs, so it won’t be helpful here.

    The issue here basically is that you are using the European date format, for which the JS sorting library does not have an algorithm by default. That is however available after installing the TablePress Extension from http://tablepress.org/extensions/datatables-sorting-plugins/

    Regards,
    Tobias

    Thread Starter RGOnline

    (@rgonline)

    Brilliant thanks, i srill need the other plugin as id like to only display today and future dates too.

    Great help

    Cheers

    Plugin Author Tobias Bäthge

    (@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!

    Thread Starter RGOnline

    (@rgonline)

    done, thanks Tobias

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks! I really appreciate it!

    Best wishes,
    Tobias

    I have problems sorting my tables by date: http://theatergemeinde-heidelberg.de/vorstellungstermine/

    I’ve already installed the datatables sorting plugin.
    I use tablepress 1.4

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    We might have to explicitly tell the DataTables JS library to use European date sorting. For that, please add this to the “Custom Commands” (“Eigene Befehle”) text field on the “Edit” screen of the table:

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

    The 1 in the code indicates that the dates are in the second column (counting starts with 0).

    Regards,
    Tobias

    Hi Tobias,

    thanks for the code. It is working to sort in frontend for the visitor. But when I edit the table I can’t sort it by date.

    Do you have a hint how to solve that?

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yeah, unfortunately, this will only add the sorting to the frontend. The reason for this is that the “Edit” screen uses a different JavaScript library for the sorting. Unfortunately, that one is not as powerful as the library that is used on the frontend, and it can not be extended with custom sorting algorithms 🙁 Now, I do have plans to change this in the future, when I rewrite the “Edit” screen for more features and better performance, but that will still take some time.
    Meanwhile, I can only suggest to maybe do the sorting not directly in TablePress, but e.g. in Excel (if it’s more data than what can be sorted manually). This means, that you could export the table to a CSV file, open that in Excel, sort the data, and then re-import the table into TablePress, choosing to replace the existing table.

    Regards,
    Tobias

    Thank you for the explanation.

    How can I specify that the table for the user is always sorted by the date?

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    sure, no problem! The best way would probably be to sort the table beforehand (using that Excel approach). You could however also tell the JS sorting library to perform an initial sorting when the page is loaded. For that, extend the “Custom Command” from above to

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

    Regards,
    Tobias

    Thank you for helping me with that!

    Plugin Author Tobias Bäthge

    (@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!

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Sorting By Date’ is closed to new replies.