You've already forked lazarus-ccr
fix rxdbgrid sort engine for ZEOS
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2530 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -15,7 +15,7 @@ type
|
||||
TZeosDataSetSortEngine = class(TRxDBGridSortEngine)
|
||||
public
|
||||
procedure Sort(Field:TField; ADataSet:TDataSet; Asc:boolean; SortOptions:TRxSortEngineOptions);override;
|
||||
procedure SortList(ListField:string; ADataSet:TDataSet; Asc:boolean);override;
|
||||
procedure SortList(ListField: string; ADataSet: TDataSet; Asc: array of boolean; SortOptions: TRxSortEngineOptions); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -51,35 +51,48 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TZeosDataSetSortEngine.SortList(ListField:string; ADataSet:TDataSet; Asc:boolean);
|
||||
procedure TZeosDataSetSortEngine.SortList(ListField: string;
|
||||
ADataSet: TDataSet; Asc: array of boolean; SortOptions: TRxSortEngineOptions);
|
||||
var
|
||||
S:string;
|
||||
i, C:integer;
|
||||
begin
|
||||
if not Assigned(ADataSet) then exit;
|
||||
if ADataSet.ClassName='TZReadOnlyQuery' then
|
||||
|
||||
S:='';
|
||||
C:=Pos(';', ListField);
|
||||
i:=0;
|
||||
while C>0 do
|
||||
begin
|
||||
(ADataSet as TZReadOnlyQuery).SortedFields:=ListField;
|
||||
if Asc then
|
||||
(ADataSet as TZReadOnlyQuery).SortType:=stAscending
|
||||
else
|
||||
(ADataSet as TZReadOnlyQuery).SortType:=stDescending;
|
||||
end
|
||||
if S<>'' then S:=S+';';
|
||||
S:=S + Copy(ListField, 1, C-1);
|
||||
Delete(ListField, 1, C);
|
||||
|
||||
if (i<=High(Asc)) and (not Asc[i]) then
|
||||
S:=S + ' DESC';
|
||||
C:=Pos(';', ListField);
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
if ListField<>'' then
|
||||
begin
|
||||
if S<>'' then S:=S+';';
|
||||
S:=S + ListField;
|
||||
if (i<=High(Asc)) and (not Asc[i]) then
|
||||
S:=S + ' DESC';
|
||||
end;
|
||||
|
||||
(ADataSet as TZAbstractRODataset).SortedFields:=S;
|
||||
|
||||
{ if ADataSet.ClassName='TZReadOnlyQuery' then
|
||||
(ADataSet as TZReadOnlyQuery).SortedFields:=S
|
||||
else
|
||||
if (ADataSet.ClassName='TZQuery') or (ADataSet is TZMacroQuery) then
|
||||
begin
|
||||
(ADataSet as TZQuery).SortedFields:=ListField;
|
||||
if Asc then
|
||||
(ADataSet as TZQuery).SortType:=stAscending
|
||||
else
|
||||
(ADataSet as TZQuery).SortType:=stDescending;
|
||||
end
|
||||
(ADataSet as TZQuery).SortedFields:=S
|
||||
else
|
||||
if ADataSet.ClassName='TZTable' then
|
||||
begin
|
||||
(ADataSet as TZTable).SortedFields:=ListField;
|
||||
if Asc then
|
||||
(ADataSet as TZTable).SortType:=stAscending
|
||||
else
|
||||
(ADataSet as TZTable).SortType:=stDescending;
|
||||
end;
|
||||
(ADataSet as TZTable).SortedFields:=S}
|
||||
end;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user