procedure SortDBGridEh(Sender: TObject; ACol: Integer; Column: TColumnEh);
var
FieldName : string ;
SortStr : string ;
begin
Screen.Cursor : = crSQLWait;
try
if (Sender is TDBGridEh) and ((Sender as TDBGridEh).DataSource.DataSet <> nil) then
begin
if not ((Sender as TDBGridEh).DataSource.DataSet is TCustomADODataSet) then
Exit;
if not (Sender as TDBGridEh).DataSource.DataSet.Active then
Exit;
FieldName : = Column.FieldName;
if (Sender as TDBGridEh).DataSource.DataSet.FindField(FieldName).IsBlob then
Exit;
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.SortMarker of
smNoneEh:
begin
TCustomADODataSet((Sender as TDBGridEh).DataSource.DataSet).Sort : = FieldName + ' DESC ' ;
end;
smUpEh:
begin
TCustomADODataSet((Sender as TDBGridEh).DataSource.DataSet).Sort : = FieldName + ' DESC ' ;
end;
smDownEh:
begin
TCustomADODataSet((Sender as TDBGridEh).DataSource.DataSet).Sort : = FieldName;
end;
end;
end;
finally
Screen.Cursor : = crDefault;
end;
end;
var
FieldName : string ;
SortStr : string ;
begin
Screen.Cursor : = crSQLWait;
try
if (Sender is TDBGridEh) and ((Sender as TDBGridEh).DataSource.DataSet <> nil) then
begin
if not ((Sender as TDBGridEh).DataSource.DataSet is TCustomADODataSet) then
Exit;
if not (Sender as TDBGridEh).DataSource.DataSet.Active then
Exit;
FieldName : = Column.FieldName;
if (Sender as TDBGridEh).DataSource.DataSet.FindField(FieldName).IsBlob then
Exit;
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.SortMarker of
smNoneEh:
begin
TCustomADODataSet((Sender as TDBGridEh).DataSource.DataSet).Sort : = FieldName + ' DESC ' ;
end;
smUpEh:
begin
TCustomADODataSet((Sender as TDBGridEh).DataSource.DataSet).Sort : = FieldName + ' DESC ' ;
end;
smDownEh:
begin
TCustomADODataSet((Sender as TDBGridEh).DataSource.DataSet).Sort : = FieldName;
end;
end;
end;
finally
Screen.Cursor : = crDefault;
end;
end;