• Resolved mpbaweb

    (@mpbaweb)


    Hi.
    I have several tables on my page https://www.mpba.org.uk/national-drivers-championship/
    Each table has a ‘Total’ column that is the sum of each row in the table. This works fine. However, I would like to be able to sort on this column.
    I have made a workaround whereby I have a hidden ‘sort’ column where I manually order the totals, but this is very tedious and time-consuming.
    How can I sort on the calculated column directly?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Sorting this would only be possible on the client side, using JavaScript.
    You could for example instruct the DataTables JS library to perform an initial sort on that column, by adding something like this to the “Custom Commands” textfield on the table’s “Edit” screen:

    "order": [[ 13, 'desc' ]]
    

    Regards,
    Tobias

    Thread Starter mpbaweb

    (@mpbaweb)

    Thanks. I’ll give it a go. The sort only needs occur on initial load and render of the table.
    *** Update *** That worked perfectly. Brilliant. Saves me a lot of pain. Great Plugin

    • This reply was modified 7 years, 8 months ago by mpbaweb.
    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 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sort calculated column’ is closed to new replies.