OnSortChange

Class: TEgFireGrid

property OnSortChange: TEgFireGridSortChangeEvent;

TEgFireGridSortChangeEvent = procedure(Sender: TObject; Column: TEgFireGridColumn;
  Direction: TEgFireGridSortDirection) of object;

Occurs when a click on a title has changed the sort direction of its column; Column is that column and Direction is the new direction. The grid does not sort: the handler applies the order to the dataset, for example with FireDAC’s IndexFieldNames or a new query.

A click on a title fires OnTitleClick, then changes the sort, then fires this event. Only one column is sorted at a time: the others go back to fgsNone. What the click does depends on the column’s Sortable: with fscBoth (the default) it alternates between ascending and descending; with fscAscending or fscDescending it alternates between that direction and none; with fscNone it changes nothing and this event does not occur. A click on a title’s icon never sorts.

procedure TForm1.Grid1SortChange(Sender: TObject; Column: TEgFireGridColumn; Direction: TEgFireGridSortDirection);
begin
  case Direction of
    fgsAscending: Query1.IndexFieldNames := Column.FieldName;
    fgsDescending: Query1.IndexFieldNames := Column.FieldName + ':D';
  else
    Query1.IndexFieldNames := '';
  end;
end;

The grid’s handler runs first, then the column’s own event of the same name.

See Also

(C) 2026 Easygate, Lda