Per-column default sort order?

Per-column default sort order?

gyozakinggyozaking Posts: 1Questions: 1Answers: 0

Consider a table of data about e-commerce websites. The table contains URL, site name, annual revenues, conversion rate, homepage load time, country, etc. We assume that when a typical user clicks on the heading of a performance-based column they want to see the sites in order of "best" to "worst" according to that metric. In the case of revenues and conversion rate, that's descending order. In the case of load time, it's ascending order. So, the default sort behavior should vary by column.

The only way I know of accomplishing this is to set the data-order attribute to be the negative of the values in those columns that should default to descending so that when the heading is clicked it's sorting ascending on the negative values which results in the real values being shown in descending order. But is there a way to properly set a per-column default -- one that works for alpha values, too? If not, is there a similar trick to handling the ascending/descending indicator in the headings so that it indicates the opposite of what it's actually doing?

Answers

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921
    edited December 2019

    Are you asking to change the order sequence from ascending first to descending first when clicked? If so then columns.orderSequence may be what you are looking for.

    Kevin

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Another option would be to set that negative value in columns.render for type sort,

    Colin

This discussion has been closed.