IDataSort Interface
Describes a single sort criterion. Data providers accept an array of IDataSort objects (via setSortList), allowing multi-column sorting where the order of the array determines sort priority.
Pass an array of IDataSort to setSortList or use it as the sortList constructor option.
import type { IDataSort } from '@katlux/providers'
// 1. Single column sort — ascending by name
const sortByName: IDataSort[] = [
{ field: 'name', direction: 'asc' }
]
// 2. Multi-column sort — by department asc, then salary desc
const multiSort: IDataSort[] = [
{ field: 'department', direction: 'asc' },
{ field: 'salary', direction: 'desc' }
]
// Apply to any provider
provider.setSortList(sortByName)
// Pass an empty array to clear all sorting
provider.setSortList([])
// On the server (after JSON.parse of URL query param):
// sortList arrives as: [{"field":"name","direction":"asc"}]
const sortList: IDataSort[] = query.sortList
? JSON.parse(query.sortList as string)
: []| Property | Type | Description |
|---|
| field | string | The key name of the field on a TDataRow object to sort by. |
| direction | 'asc' | 'desc' | Sort direction. 'asc' for ascending (A→Z, 0→9), 'desc' for descending (Z→A, 9→0). |