• Resolved mchiampa

    (@mchiampa)


    Hi Tobias,

    I love your plugin. Super clean and easy to use so thanks!

    I have a table that includes dates in the US format which sorts properly. Unfortunately I have some rows where the date is TBD and I am stuck as to what to do. I want these rows to sort as if they are the last date, since if they are TBD it means they are probably after the dates already in the table.

    If I type in “TBD” as text, it breaks the filtering for the dates. If I leave them blank, the rows are sorted as if the blank rows are 0 and thus come first.

    Can you think of a way to have these blank date rows sorted last?

    Not super serious but I figured it was worth asking.

    Thanks!

    http://wordpress.org/plugins/tablepress/

Viewing 1 replies (of 1 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    I see what you are trying to do, but unfortunately, I don’t have a solution to this yet 🙁 The date sorting is done via the external DataTables JS library, and modifying this sort behavior would require some extra coding to basically come up with a custom data format.

    Instead, I could imagine a (kind of hacky) workaround: Basically, you could duplicate the current column with the dates, and in the copy replace all “TBD” with something like “01/01/2099”, i.e. a date in the far future. Then, it is possible to hide that column from the user, but tell the sorting algorithm to use the data in that column whenever a user wants to sort on the actual column with the dates (and “TBD”s). To make that work, you’d just have to add this to the “Custom Commands” textfield on the “Edit” screen of the table, after creating that copied columns as described:

    "aoColumnDefs": [ { "iDataSort": 1, "aTargets": [ 0 ] }, { "bVisible": false, "aTargets": [ 1 ] } ]

    This would tell the first column (indicated by the 0) to use the data from the second column (indicated by the first 1), while it would also hide the second column (indicated by the second 1 in the code). (Counting columns starts with 0 for this code.)

    Regards,
    Tobias

Viewing 1 replies (of 1 total)
  • The topic ‘Date sorting issue with text’ is closed to new replies.