Sorting Technical Reference

View as Markdown

Custom Sort State

CustomSortState

Custom Sort section of Adaptable State, including Initial State.

Each entry replaces the normal sort of one column with the order in SortedValues. Values in that list sort in list order. Values absent from the list sort after them, using the normal comparison. A custom sort comparer registered for the column is used instead of SortedValues.

Extends

BaseState

Custom Sorts to apply. One column uses the first Custom Sort whose ColumnId matches.

Custom Sort

CustomSort

A column sorted in a fixed order instead of the normal comparison.

ColumnId is the column. SortedValues is the order: listed values come first, in that order, and any other value sorts after them. Date values are stored as ISO dates (yyyy-MM-dd). Suspend with IsSuspended.

ColumnId

string

Id of Column on which Custom Sort will be applied

Name

string

Name of the Custom Sort definition

SortedValues?

(string | number)[]

Sort order. Listed values come first, in this order. Any other value sorts after them. Dates are stored as ISO strings (yyyy-MM-dd).

IsReadOnly?

boolean

Sets Entity to ReadOnly (overwriting a Strategy Entitlement of 'Full')

IsSuspended?

boolean

Suspends (i.e. turns off) an Adaptable Object


Custom Sort Options

customSortComparers entries are a ColumnValuesComparer:


Custom Sort API

CustomSortApi

Custom sort orders for columns: the values to show first, and which sorts are active.

Adds a Custom Sort to Custom Sort collection in Adaptable State

Creates new Custom Sort based on given values

Removes Custom Sort for a given ColumnId

Edits a Custom Sort

Updates existing Custom Sort with new set of Sorted Values

Retrieves all Custom Sorts that are active (not-suspended) in Adaptable State

Retrieves Custom Sort by the technical ID (from CustomSortState)

Retrieves a Custom Sort by its Name

Retrieves Custom Sort from Adaptable State for Column with given ColumnId

Retrieves all Custom Sorts in Adaptable State

Retrieves Custom Sort section from Adaptable State

Returns all Custom Sort Comparers in Custom Sort Options that are currently applied

Retrieves all Custom Sorts in Adaptable State that are currently applied

Retrieves all Custom Sorts that are suspended in Adaptable State

Opens Settings Panel with Custom Sort section selected and visible

Suspends all Custom Sorts

Suspends Custom Sort

Activates all suspended Custom Sort

Un-suspends or activates a suspended Custom Sort


Grid Sorted Event

AdapTable fires the Grid Sorted Event whenever any column in AdapTable is sorted.

It provides information on what is being sorted in AdapTable.

Find Out More

This is often used when wanting to manage expressions on the Server

GridSortedInfo

The GridSortedInfo object provided by the event returns a single object:

The AdaptableSortState object provides information on what is being sorted in AdapTable.

Each columnSorts entry is a ColumnSort:

ColumnSort

One column in a layout sort.

On Layout.ColumnSorts, the array order is the sort priority: the first entry is the primary sort. SortOrder is 'Asc' or 'Desc'.

ColumnId

string

Id of Column being sorted

SortOrder

'Asc' | 'Desc'

How Column is sorted - either 'Asc' or 'Desc'

It contains 2 sections:

  • Column Sorts active in AG Grid
  • Custom Sorts which have been provided in Initial State (i.e. not supplied via Comparers)

Caution

Custom Sorts are always sent even if none are currently active

Event Subscription

Subscribing to the Event is done the same way as with all Adaptable Events:

api.eventApi.on('GridSorted', (eventInfo: GridSortedInfo) => {
    // do something with the info
});

Find Out More

There are also some sorting-related functions in Grid API