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: mySQLQuery1.SortFieldNames := 'ID, Name DESC, ColorValue ASC'; Since v2.6.3 double-quote character ( " ) can be used to quote field name if one contain spaces, commas or other non-alphanumeric character. For example: mySQLQuery1.SQL.Clear; 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 this fields after opening. This property can also be used at Design-time. Since v2.7.6 you can adjust case sensitivity of sorting using TMySQLDatabase.DatasetOptions property. Example: This code can be used to sort data in TDBGrid component by particular column when user clicks on its title. procedure TForm1.DBGrid1TitleClick(Column: TColumn); See also: SortBy method, TMySQLDatabase.DatasetOptions property |