Specifies field names and sorting order to sort opened dataset by these fields on the client side without refetching data from server. Syntax: property SortFieldNames : string; Description: Set SortFieldNames to establish or change the list of fields on which the dataset is sorted. Set sort to the name of a single field or to a comma-separated list of fields. Every field name can be followed by the keyword 'ASC' or 'DESC' to specify a sort direction for the field. If one of these keywords is not used, the default sort direction for the field is ascending ('ASC'). For example: PSQLQuery1.SortFieldNames := '"ID", name DESC, "ColorValue" ASC'; The given names are treated like identifiers in an SQL command, that is, they are downcased unless double-quoted. If dataset is opened setting this property to some string causes sorting of dataset immediately. If dataset is closed (Active = false) it will be sorted by these fields after opening. This property can also be used at design-time. Example: This code can be used to sort data in TDBGrid component by particular column when user clicks on it title. procedure TForm1.DBGrid1TitleClick(Column: TColumn); See also: SortBy |