A very practical EHLIB sort function, suitable for ADO
EHLIB3.0, although supports the sorting function, do not support the SQL statement with ORDER BY, and the sort is very slow; the sorting function I wrote, using the ADO's Sort method, the sort is very fast, tens of thousands of data is also very fast . This function supports the Lookup field sort, does not support the calculation field sort because the calculation field value is in the memory. Sort is divided into: ascending, descending, and default, support the sort icon. procedure SortDBGridEh (Sender: TObject; ACol: Integer; Column: TColumnEh); var FieldName, SortStr: string; begin Screen.Cursor: = crSQLWait; try if (Sender is TDBGridEh) and ((Sender as TDBGridEh) .DataSource.DataSet < > nil) The begin if not ((Sender as tdbgrideh) .datasource.dataset is tcustomadodataset) THEN EXIT;
If not (sender as tdbgrideh) .datasource.dataset.active kiln
FieldName: = column.fieldname; if (sender as tdbgrideh) .datasource.DataSet.Findfield (FieldName) .isblob kiln.
if (Sender as TDBGridEh) .DataSource.DataSet.FieldByName (FieldName) .FieldKind = fkData then SortStr: = FieldName else if (Sender as TDBGridEh) .DataSource.DataSet.FieldByName (FieldName) .FieldKind = fkLookup then FieldName: = (Sender as tdbgrideh) .datasource.DataSet.fieldbyname (FieldName) .Keyfields else fieldname: = '';
IF (FieldName = ') OR (POS ('; ', FieldName> 0) THEN EXIT; case column.title.sortmartr of smnoneeh: begin column.title.sortmarker: = SMUPEH; TCUSTOMADODATASET ((Sender AS TDBGRIDEH). DataSource.Dataset .sort: = fieldName;