vcl-cxcustomdata-dot-tcxcustomdatacontroller-2532be0c.md
Allows you to respond to sorting changes.
property OnSortingChanged: TNotifyEvent read; write;
You can handle the OnSortingChanged event to execute custom code in response to data sorting changes.
Note
If the data controller is in Grid Mode, you need to handle the OnSortingChanged event to implement the data sort functionality.
The OnSortingChanged event occurs every time a sort operation completes. For example, a click on a column header in a grid Table View or a SortOrder property value change for a data item starts a new sort operation.
You can use the Sender parameter to identify and access the TcxCustomDataController class descendant instance that raised the OnSortingChanged event.
Tip
You need to cast the Sender parameter value to the corresponding terminal TcxCustomDataController class descendant to access all public API members. Call the Sender.ClassType function to identify the actual data controller type.
Refer to the TNotifyEvent procedural type description for additional information on the event type.
The following code example moves focus to the top record after a sort operation:
procedure TMyForm.cxGrid1TableView1DataControllerSortingChanged(Sender: TObject);
begin
(Sender as TcxCustomDataController).FocusedRowIndex := 0;
end;
void __fastcall TMyForm::cxGrid1TableView1DataControllerSortingChanged(TObject *Sender)
{
dynamic_cast<TcxCustomDataController*>(Sender)->FocusedRowIndex = 0;
}
Alternatively, you can add the dcoFocusTopRowAfterSorting flag to the Options property value.
See Also
TcxCustomDataController.Options Property
TcxCustomGridTableItem.SortOrder Property