# Sorting
Adding sorting is quite straightforward:
- Add
sortable
property to column - enables sorting triggering on header click; - Add
order
property to column - makes column sorted inasc
ordesc
order by default;
# Sorting events
beforeSorting
-CustomEvent<{ column: RevoGrid.ColumnRegular, order: 'desc'|'asc' }>
. Triggered after header click before sorting started. Usee.preventDefault()
in case you want prevent any farther sorting chain,beforeSortingApply
will not be triggered.beforeSortingApply
-CustomEvent<{ column: RevoGrid.ColumnRegular, order: 'desc'|'asc' }>
. Triggered before sorting data get applied. Usee.preventDefault()
in case you want avoid data sorting and apply your own, at this case don't forget to look atbeforeSourceSortingApply
to prevent additionaly sorting during source apply.beforeSourceSortingApply
-CustomEvent
. Triggered before sorting apply onsource
data change. Usee.preventDefault()
in case you don't need auto sorting apply when newsource
income.
For more details please look at API section and column data schema interfaces.
const columns = [{
name: 'Person name',
prop: 'name',
sortable: true,
order: 'asc'
}];