Ordering from right to left?

Ordering from right to left?

RedDog85RedDog85 Posts: 2Questions: 1Answers: 0
edited June 17 in ColReorder

I'm currently using HubSpot to display a lot of data in a table across 13 columns. Using DataTables I am able to order this data based on the 13th column which works perfectly.

"order": [[ 12, 'asc' ]] /* columns from left to right starting at 0 */

However, as this module is reused across many pages on my website, I've written a condition which hides the first column if you're on a particular page, meaning that you may only see 12 columns - breaking the order value.

Is there a way to reverse the order to read right to left so my 13th column becomes 0?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 12,490Questions: 0Answers: 2,119
    Answer ✓

    Not as such, but you can do a sum in the order so that it calculates how many columns there are before anything is hidden, something like this example here:

        order: [$('thead th').length-1, 'asc']
    

    Colin

  • kthorngrenkthorngren Posts: 13,625Questions: 25Answers: 3,205

    Is there a way to reverse the order to read right to left so my 13th column becomes 0?

    No, the numbering is using Javascript indexes.

    I've written a condition which hides the first column if you're on a particular page, meaning that you may only see 12 columns - breaking the order value.

    How are you hiding the column? If you use columns.visible with the 13 columns then the index should still be correct.

    Kevin

  • RedDog85RedDog85 Posts: 2Questions: 1Answers: 0

    Hi @kthorngren I'm using HubSpots own HubL language to hide the column as it gives me a lot of flexibility. That said, I wasn't aware of the 'columns.visible' option. I will bare this in mind going forward. Thanks for the heads up.

Sign In or Register to comment.