• Resolved thibgfr

    (@thibgfr)


    Hi Tobias,

    First, thank’s for your great work !
    We’re having trouble getting our table to sort in date order.
    We’re using the european format dd/mm/yyyy in the table but it only sort alphabetically.

    We want to sort the table by expiry date (Fifth column “Expire le”) and to filter because we only want to show 4 rows.
    We downloaded the DataTables Sorting plugins Extension 1.0.
    We had the custom command :
    "columnDefs": [ { "type": "date-eu", "targets": [ 4 ] } ]
    And the command to show the table is :
    [table id=1 row_order=sort row_order_sort_column=E row_order_sort_direction=ASC hide_rows="all" show_rows="1,2,3,4,5" /]

    Here the result : http://tendance-talons.com/publicite
    (First table : the unsorted one; Second table : our problem)

    Regards,
    Thibault

    https://wordpress.org/plugins/tablepress/

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

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    I’m afraid that this will not really work like this 🙁

    The “Custom Command” (with the Extension) would only sort on the frontend. You however want to sort by date when the table data is generated (I assume that you want the 5 newest rows).
    This can not really be done automatically, because of the date format, but also because of the sorting.

    Unfortunately, I don’t really see a solution here, except manually creating the desired order 🙁 (This should not be difficult, because you can simply drag and drop the rows into the new order on the “Edit” screen, by clicking and holding the row number.)

    Regards,
    Tobias

    Thread Starter thibgfr

    (@thibgfr)

    Hi,

    Thanks for your help but we can’t just simply drag and drop as we want to sort 3 tables and it’s a waste of time.

    Our main problem is that we can’t order by european dates.
    We downloaded and activated the DataTables Sorting plugins Extension 1.0.
    We had this custom command : »columnDefs »: [ { « type »: « date-eu », « targets »: [ 4 ] } ]
    And we simplified the command :

    [table id=2 hide_columns="6" /]
    [table id=2 row_order=sort row_order_sort_column=E hide_columns="6"/]

    Link to the result : http://tendance-talons.com/publicite

    As you can see it’s an alphabetically order… What is wrong ?

    Regards,
    Thibault

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    as mentioned above, the Table Row Order Extension is of no use here. It can not sort for European dates, so that you can remove it’s Shortcode parameter.

    Using the “Custom Command”

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

    is correct, but this only defines the data type. To perform an initial sorting, you’ll have to extend it to

    "columnDefs": [ { "type": "date-eu", "targets": [ 4 ] } ], "order": [[ 4, 'asc' ]]

    For the Shortcode, use

    [table id=2 hide_columns="6" /]

    Regards,
    Tobias

    Thread Starter thibgfr

    (@thibgfr)

    Hi,

    You’re fast ! Thank’s !
    I copy/paste these instructions but nothing has change… ?

    Our order is
    table id=2 hide_columns="6"
    And our “Custom Command” is now
    "columnDefs": [ { "type": "date-eu", "targets": [ 4 ] } ], "order": [[ 4, 'asc' ]]

    But as you can see (Link : http://tendance-talons.com/publicite) there isn’t an perform as initial sorting. Did we miss something ?
    (The extensions are activated.)

    Regards,
    Thibault

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    you must enable the “Sorting” checkbox on the table’s “Edit” screen.

    Regards,
    Tobias

    Thread Starter thibgfr

    (@thibgfr)

    Hi,

    Finally it works, thank’s a lot !

    Have a nice day,
    Regards,
    Thibault

    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!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: DataTables Sorting plugins] Sorting by european dates’ is closed to new replies.