Sorts opened dataset on client side without refetching data from server. Syntax: procedure SortBy(FieldNames : string); Description: Call SortBy to sort dataset by particular fields on client side. Field names are case-sensitive and separated by commas. 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.SortBy('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; This method affects dataset order only when it is opened, i.e. when Active = True. 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 it title. procedure TForm1.DBGrid1TitleClick(Column: TColumn); See also: SortFieldNames, TMySQLDatabase.DatasetOptions properties |