- Delphi Cookbook
- Daniele Spinetti Daniele Teti
- 237字
- 2025-04-04 16:22:46
How it works...
The core concepts of this recipe are enclosed in the DBGrid1TitleClick and CustomerInfoClick functions.
In the first procedure, we used the IndexFieldNames property to generate a temporary index to perform sorting based on a field related to the DBGrid column clicked, and also applying a graphical change to the column to better understand the ordering.
A temporary index accepts more than one field, so if you want to sort data by several fields you can do it by separating fields, with a semicolon.
In addition, you can also specify the sort order, such as ascending or descending, adding the suffixes :A for ascending and :D for descending.
In addition, you can also specify the sort order, such as ascending or descending, adding the suffixes :A for ascending and :D for descending.
In the second procedure, we used Aggregate to report some customer info:
- Total Value: This represents the total amount of all orders
- Max Value: This represents the order with the maximum amount
- Last Order: This represents the last date order
Aggregate are created in the CreateAggregates procedure. Here is some more information about the properties used:
- Expression property: This defines the expression to be used to calculate the aggregate.
- GroupingLevel property: This defines the number of indexed fields to use for grouping. By default, its value is set to 0 (no fields and no grouping; all records in a dataset).
- IndexName property: This defines the name of the index to use for grouping. If none is specified, it will use the IndexName property of DataSet.