close

Filter

loading table of contents...

Studio Developer Manual / Version 2110

Table Of Contents

9.15.6 Make Columns Sortable in Search and Repository View

Sorting can be enabled for custom columns by setting two mandatory attributes in the gridcolumn definition. The attribute sortable has to be set to true to enable sorting. The attribute sortField has to specify the Solr index column that should be used for sorting.

import Config from "@jangaroo/runtime/Config";
import Column from "@jangaroo/ext-ts/grid/column/Column";

//...
Config(Column, {
  sortable: true,
  dataIndex: "creator",
  header: "Creator",
  sortField: "creator",
})

Example 9.60. Two additional attributes for sorting.


The optional field sortDirection enables you to restrict the sort direction to only one direction. This is useful if sorting does only make sense in one direction. For example a user is usually not interested in the less relevant search result. So you want to disable sorting for relevance ascending. Possible values are "asc" or "desc" where the value is the enabled sort direction.

import Config from "@jangaroo/runtime/Config";
import Column from "@jangaroo/ext-ts/grid/column/Column";

//...
Config(Column, {
  sortable: true,
  dataIndex: "creator",
  header: "Creator",
  sortField: "creator",
  sortDirection: "desc",
})

Example 9.61. Optional sortDirection Attribute to enable only one sort direction.


You can make even hidden grid columns sortable. Hidden columns are not shown in the grid but users can select them from the sort drop down field. This is useful if columns do not have meaningful values (again relevance for example) or if you just do not want to blow up the grid too much. Hidden columns that do not have their hideable config option set to false can also be unhidden by the user using the grid header menu.

At last you can define one default sort column for each list in the collection view. The default sort column will be used when the user has not specified a sort criteria. To configure add the attribute defaultSortColumn with value true. For more fine grained configuration the attribute defaultSortDirection can be set to asc or desc to sort ascending or descending by default.

import Config from "@jangaroo/runtime/Config";
import Column from "@jangaroo/ext-ts/grid/column/Column";

//...
Config(Column, {
  sortable: true,
  dataIndex: "creator",
  header: "Creator",
  sortField: "creator",
  defaultSortColumn: true,
  defaultSortDirection: "desc",
})

Example 9.62. defaultSortColumn Attribute to configure one column as the default for sorting.


Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.