• Resolved wardenofthenorth

    (@wardenofthenorth)


    Hello, i have a sorting question, but not one where i wanted it sorted prior to the user clicking on that particular column.

    So, I want the table data to display how I have it initially entered, no additional sorting by formula; however, when let’s say the last column (let’s say they are numbers) is clicked on, i want it to immediately sort from high to low (vs low to high).

    Reason: I don’t want the user to have to click on the last column to sort by that figure in that column, then to have to click it again, as initially it sorts lowest to high when first clicked on, but I would never want this (I’d always want the first click/sort to organize highest to low.

    Is this possible without affecting the table’s initial loading without sorting going on?

    Thanks so much!

    https://www.ads-software.com/plugins/tablepress/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter wardenofthenorth

    (@wardenofthenorth)

    Oh, and if i could trouble you to insert it into this code I have already, as I probably wouldn’t know how to properly mingle the two… so I’d like whatever you are able to assist me with to be used in conjunction with the below, so a person might search using colums 1 and 2 but i dont want that person to have any sorting yet (highest to low) until they decide themselves to click on let’s say column 12 or 11:

    "columnDefs": [ { "searchable": false, "targets": [ 0,3,4,5,6,7,8,9,10,11,12 ] } ]

    (so again, despite the user being able to search only colums 1 and 2, I do not want the sorting to take place until the user clicks on column 12 or 11, but when they do, i want it right away to be highest to low) – hope that makes sense ??

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    This is what should work for this:

    "columnDefs": [ { "searchable": false, "targets": [ 0,3,4,5,6,7,8,9,10,11,12 ] }, { "orderSequence": [ "desc", "asc" ], "targets": [ 11, 12 ] } ]

    Regards,
    Tobias

    Thread Starter wardenofthenorth

    (@wardenofthenorth)

    I’m sorry, can you make one change to the code? Once searched, can it automatically sort by highest to low, before the user clicks on the column? So as it stand snow, the user would have to click on the column.. can you have it so when searched, it automatically goes high to low from the last column? 12?

    Thread Starter wardenofthenorth

    (@wardenofthenorth)

    1. So automatically sort high to low using column 12,
    2. but clicking on column 11 would automatically sort high to low.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    sorry, searching can not trigger a sort. For that, you would need other customizations with DataTables. Doing it with such a “Custom Command” is not possible, from what I know.

    Regards,
    Tobias

    Thread Starter wardenofthenorth

    (@wardenofthenorth)

    ok, well, this works good still.. thanks so much, great support, great plugin!

    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 ‘Sorting highest to low, but only when column clicked on’ is closed to new replies.