Sorting Technical Reference

Summary

  • Custom Sorting is provided in 2 ways:
    • Through Custom Sort State (hardcoded values)
    • Via customSortComparers function in Custom Sort Options
  • Run-time access to Custom Sorting is via Custom Sort API
  • Grid API contains more general sorting functions
  • The Grid Sorted Event fires whenever sorting changes in AG Grid

Custom Sort State

The Custom Sort section of Initial Adaptable State contains a list of CustomSort objects:

Custom Sort Object

PropertyDescription
CustomSortsCollection of Custom Sort objects.

A CustomSort object contains simply a ColumnId and a list of values to use for the sort:

PropertyDescription
ColumnIdId of Column on which Custom Sort will be applied
NameName of the Custom Sort definition
SortedValuesOrder of values by which Column will be sorted; Date values are persisted as ISO strings ('yyyy-MM-dd')
IsReadOnlySets Entity to ReadOnly (overwriting a Strategy Entitlement of 'Full')
IsSuspendedSuspends (i.e. turns off) an Adaptable Object

Custom Sort Options

The Custom Sort Options is used to provide Custom Sort Comparers:

PropertyDescription
customSortComparersCustomSort column comparer functions

Custom Sort API

The Custom Sort API provides comprehensive programmatic access to Custom Sorting.

It includes these functions:

MethodDescription
addCustomSort(customSort)Adds a Custom Sort to Custom Sort collection in Adaptable State
createCustomSort(params)Creates new Custom Sort based on given values
deleteCustomSort(columnId)Removes Custom Sort for a given ColumnId
editCustomSort(customSort)Edits a Custom Sort
editCustomSortValues(columnId, values)Updates existing Custom Sort with new set of Sorted Values
getActiveCustomSorts(config)Retrieves all Custom Sorts that are active (not-suspended) in Adaptable State
getCustomSortById(id, config)Retrieves Custom Sort by the technical ID (from CustomSortState)
getCustomSortByName(name)Retrieves a Custom Sort by its Name
getCustomSortForColumn(columnId)Retrieves Custom Sort from Adaptable State for Column with given ColumnId
getCustomSorts(config)Retrieves all Custom Sorts in Adaptable State
getCustomSortState()Retrieves Custom Sort section from Adaptable State
getLiveCustomSortComparers()Returns all Custom Sort Comparers in Custom Sort Options that are currently applied
getLiveCustomSorts()Retrieves all Custom Sorts in Adaptable State that are currently applied
getSuspendedCustomSorts(config)Retrieves all Custom Sorts that are suspended in Adaptable State
openCustomSortSettingsPanel()Opens Settings Panel with Custom Sort section selected and visible
suspendAllCustomSort()Suspends all Custom Sorts
suspendCustomSort(customSort)Suspends Custom Sort
unSuspendAllCustomSort()Activates all suspended Custom Sort
unSuspendCustomSort(customSort)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:

PropertyDescription
adaptableSortStateCurrent sort state in the Grid
adaptableContextCustom application Context provided in AdaptableOptions.adaptableContext

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

PropertyDescription
columnSortsColumns currently being sorted (with direction)
customSortComparersCustom Sort Comparers which are currently applied
customSortsCustom Sorts which are currently applied

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