Sorting a column by a value different than visible display

Sorting a column by a value different than visible display

schwimschwim Posts: 4Questions: 2Answers: 0

Hi there everyone!

I've got a column I'd like to sort. It's a time spent row and It's run through a function to make seconds human readable so instead of 613, it shows "10 minutes, 13 seconds". I tried to place the seconds in a span around the human readable number

span class="4201"

But it's not working, it will still sort like the following:

10 minutes
9 hours, 10 mins
8 minutes
7 days, 1 hour, 45 mins

How would I get this column to sort by the seconds without making it visible in the td?

Thanks for your time!

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,321Questions: 26Answers: 4,773
    Answer ✓

    You can use Orthoganl Data for this. Simply return the seconds value for the sort and filter types. Then return the human readable for everything else.

    Kevin

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    Alternatively, return your seconds in a hidden column and use it for sorting from your "human" column.

           columns: [
                // Sort column 1 (human) using data from column 2 (seconds).
                {
                    data: "human" ,
                    orderData: [2]
                },
                {
                    data: "seconds",
                    visible: false,
                    searchable: false
                },
    ....
    
  • schwimschwim Posts: 4Questions: 2Answers: 0

    You guys are incredible. I can't thank you enough for all the help!

This discussion has been closed.