SortChangingEventArgs
Description
A SortChangingEventArgs
is an interface that extends the EventArgs
interface and exposes additional properties to specify additional options for the “sortChanging” EventName
.
Properties
Property |
Type |
Description |
---|---|---|
newSortDefinitions |
The new sort to be applied, or an empty array if the sort will be removed. This property can be modified before the final sort is applied. |
|
oldSortDefinitions |
readonly |
The old sort, or an empty array if there was no sort. |
sortAction |
The sort action that triggered the sort. |
Example
In this example, an eventListener
handler is added for the “sortChanging” EventName
. It reads the SortChangingEventArgs
and if the sortAction
is not on the firstColumn
, it modifies the sort so that the first column will always be an ascending sort and will always be the primary sort.
const sortChangingEventHandler = (args) =>
{
if (args.sortAction.field !== "firstColumn")
{
const firstColumnSort = { field: "firstColumn", sortDirection: Xceed.SortDirection.Ascending };
args.newSortDefinitions.unshift(firstColumnSort);
}
}
const eventListeners = { “sortChanging”: sortChangingEventHandler };
This eventListeners
should be set on the DataGridOptions
.eventListeners
.