Sort Events and Cancellable Sort Changes
The grid fires sortChanging before a sort is applied and sortChanged after rendering. sortChanging can be cancelled or can modify the proposed model. Both events include the previous model, the next model and the source of the change, which lets apps veto sorts, log analytics or enforce business rules.
Planned. This page shows the specification from issue #186. The live example, source for every framework and the API reference replace it when the feature ships.
Live example
A task grid with an event log panel.
Expected behavior
Every click logs a sortChanging entry followed by a sortChanged entry with source='ui'. When the veto is on, clicking Notes logs only sortChanging with cancelled=true, and nothing changes in the grid. When the prefix rule is on, the final model always starts with Priority.
Planned API surface
onSortChangingonSortChangedSortChangeEvent { previousModel, nextModel, source, preventDefault, setModel }Acceptance criteria
- sortChanging fires before any reordering (pending)
- preventDefault() stops the change and suppresses sortChanged (pending)
- A model passed to setModel inside sortChanging is the one that gets applied (pending)
- sortChanged fires after the DOM has updated (pending)
- source is one of: ui, api, keyboard, initialState, server (pending)