Skip to main content

TcxCustomDataController.OnSortingChanged Event

Allows you to respond to sorting changes.

Declaration

property OnSortingChanged: TNotifyEvent read; write;

Remarks

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.

Event Occurrence

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.

Event Parameter

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.

Code Example

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;

Alternatively, you can add the dcoFocusTopRowAfterSorting flag to the Options property value.

See Also