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
| Property | Description |
|---|---|
| CustomSorts | Collection of Custom Sort objects. |
A CustomSort object contains simply a ColumnId and a list of values to use for the sort:
| Property | Description |
|---|---|
| ColumnId | Id of Column on which Custom Sort will be applied |
| Name | Name of the Custom Sort definition |
| SortedValues | Order of values by which Column will be sorted; Date values are persisted as ISO strings ('yyyy-MM-dd') |
| IsReadOnly | Sets Entity to ReadOnly (overwriting a Strategy Entitlement of 'Full') |
| IsSuspended | Suspends (i.e. turns off) an Adaptable Object |
Custom Sort Options
The Custom Sort Options is used to provide Custom Sort Comparers:
| Property | Description |
|---|---|
| customSortComparers | CustomSort column comparer functions |
Custom Sort API
The Custom Sort API provides comprehensive programmatic access to Custom Sorting.
It includes these functions:
| Method | Description |
|---|---|
| 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:
| Property | Description |
|---|---|
| adaptableSortState | Current sort state in the Grid |
| adaptableContext | Custom application Context provided in AdaptableOptions.adaptableContext |
The AdaptableSortState object provides information on what is being sorted in AdapTable.
| Property | Description |
|---|---|
| columnSorts | Columns currently being sorted (with direction) |
| customSortComparers | Custom Sort Comparers which are currently applied |
| customSorts | Custom 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