Sort Component

The sort component has the following structure:

{
  "sort": {
    "criteria": {
      "properties": [
        { "name":"name of the property",
          "sequence": 1
        },
        { "name":"name of the property",
          "sequence": 2
        }
      ]
    },
    "default": [{
      "sortOrder": "desc",
      "sequence":1,
      "properties": [
        { "name":"name of the property",
          "sequence": 1
        }
      ]
    },
    {
      "sortOrder": "asc",
      "sequence":2,
      "properties": [
        { "name":"name of the property",
          "sequence": 1
        }
      ]
    }]
  }
}

Default

When specified, the list resource is sorted based on the properties and order as defined by the default criteria. The sequence property of each default criterion determines the order in which properties are considered for sorting.

Sorting order of asc, desc, can be specified. Nulls first is applied while sorting.

Criteria

The criteria are shown in a drop-down, by default no property is selected as first pick. When a user selects a criterion, first the results are sorted ascending based on the selected criterion. The selected criterion overrides the default sort criteria and the results are ordered only based on the 'sort' criterion. When a user selects the same criterion again (which is then shown with an arrow in the opposite direction in the drop-down) the results are sorted descending. This behavior keeps toggling for the criterion. When a user selects a new criterion, the same behavior is applied to the new criterion. Nulls first is applied while sorting.

Up and down arrow against the criterion shows if the results are sorted in an ascending or a descending order.

image

At minimum one valid property (when a specified property does not exist, system ignores that property) should be specified, if no property is specified, the component is not shown in the UI.

When multiple nested properties of a reference property are part of sort (default or criteria), each nested property should be configured as separate element. Also, when such a configuration exists for criteria sort then custom labels are needed to identify the nested properties in the page.