Sorting columns

Columns can be sorted in ascending or descending order, interactively or by programming.
Interactively, the user clicks a column header once to sort it in ascending order, twice to sort it in descending order, and three times for no sorting at all. Using the Shift key while clicking the column header adds this column as a sorting criterion, whereas otherwise the column is set as the only sorting criterion.
By programming, you can use the following methods:
  • addSortingCriteriaaddSortingCriteria adds the given attribute as a sorting criterion. This method takes as its arguments:
    • the attribute corresponding to the column to be sorted
    • an order parameter that defines the position of the column among the sorting criteria
    • the ascendingOrder parameter, which, when set to true , sorts the column in ascending order
    • the parameter useDisplayValue , which indicates whether the sorting is applied to the display values (that is, with style sheets applied) or to the raw values
      Each sorted column serves as a sorting criterion. If order equals 1 , the column is selected as the first sorting criterion, if it equals 2 , it is selected as the second sorting criterion, and so on. If order is less than 1 , the column is considered as the first criterion. If order is greater than the current number of criteria, the column is considered as the next criterion.
  • getSortingOrder returns the position as a sorting criterion of the specified attribute.
  • isUsingAscendingOrder returns true if the specified attribute is sorted in ascending order.
  • isUsingDisplayValue returns true if the specified attribute is sorted by display values.
  • removeAllSortingCriteria removes all sorting criteria.
  • getSortedAttributesCount returns the number of sorted columns in the table.
Note
The sorting order can also be controlled through the " sortingMode " and " sortingPriority " properties. For more information, see Customizing column headers and rows.