• Resolved MKNN

    (@mknn)


    Couldn’t locate this by searching, but can’t imagine this is the first time to ask for it–sorry for the duplication.

    The question is how to sort by a second parameter (that is, sort by columnA, if those match, then sort by columnB). Often, the trick is to just sort by columnB and then by columnA, but that doesn’t seem to work in the admin interface. Just thought–perhaps there is a way to do this via arguments in the shortcode?

    As an example, http://wfl.dmlco.com/statistics/10-tackles/ . I would like it to sort by HIGH, and then, if there is a tie there, by GAMES.

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

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    Second-level sort is indeed not possible in the admin area (the sorting algorithm there is not very sophisticated).

    You can however do a second-level sort on the frontend, by holding down the “Shift” key when sorting for the second column.

    Regards,
    Tobias

    Thread Starter MKNN

    (@mknn)

    Is there any way to make a second level sort the “default” view for the table, so others visiting the page would also see it that way?

    If not, consider this a feature request! (Unsure if you are still updating tablePress or just supporting it.)

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no worries, TablePress will still receive updates! 🙂

    You could instruct the DataTables JS library (that performs the sorting) to perform such two-level sorting when the page is opened. For that, just add this “Custom Command” on the table’s “Edit” screen:
    "order": [ [ 0, 'asc' ], [ 1, 'asc' ] ]
    This example would perform ascending sorts on the first and then the second columns. (Note that the column numbers in this code start with 0, i.e. 0 refers to the first column, 1 refers to the second column, etc.)

    Regards,
    Tobias

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

The topic ‘Second Level Sort’ is closed to new replies.