• Resolved amanfre

    (@amanfre)


    Hi,

    When a user first comes to my site, I want rows to be sorted automatically based on text included in columns 7 & 8.

    I thought the best way here would be to include row sorting, however how can you do this based on setting a defined order. For example, I want rows to be sorted in this order:

    Live
    In XX days
    Ended

    Im aware of the other method in creating a hidden column and setting a number value to then sort this way, however the issue is that the text in columns 7 & 8 are not fixed and include shortcode for a countdown timer. So text will effectively change upon a certain date being met or expired, hence the live, days then ended words above.

    How can this be done?

    Site is https://www.stoblock.io

    Thanks
    Anthony

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

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Unfortunately, I don’t know a solution to this. The standard algorithm can’t really know that you don’t want alphabetic sorting, but a custom order. If the approach of using an extra hidden column won’t work, your only chance is to develop a custom sorting algorithm that can interpret your values and assign a sortable value to them.
    For inspiration, you could check the source of the TablePress Extension from https://tablepress.org/extensions/datatables-sorting-plugins/ and the DataTables documentation at https://datatables.net/plug-ins/sorting/

    Regards,
    Tobias

    Thread Starter amanfre

    (@amanfre)

    Thanks for the quick response Tobias.

    I think it may be easier to take a different route.

    I just noticed when I clicked on the sorting arrows for column F (sale 1), the descending arrow gives me the order that I want, being Live, In XX Days then Ended.

    How can I set this up to occur automatically everytime I go to the page without hitting the sorting arrow.

    Cheers

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    for that, add this to the “Custom Commands” text field on the table’s “Edit” screen:

    "order": [ [ 5, "desc" ] ]
    

    Regards,
    Tobias

    Thread Starter amanfre

    (@amanfre)

    Perfect, worked. Much appreciated.

    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 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Row Sorting Based on Defined Text/Numbers’ is closed to new replies.