mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-17 08:09:13 +02:00
* Correct group nesting
This commit is contained in:
parent
c1d04d45fb
commit
b0e184906e
@ -1406,27 +1406,46 @@ end;
|
|||||||
function TCustomLoopTemplateWidget.RenderGroupHeaders(aEnum : TLoopEnumerator) : String;
|
function TCustomLoopTemplateWidget.RenderGroupHeaders(aEnum : TLoopEnumerator) : String;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
GrpIdx: Integer;
|
ChangeIdx,GrpIdx: Integer;
|
||||||
grp : TLoopTemplateGroup;
|
grp : TLoopTemplateGroup;
|
||||||
StartGroups : Boolean;
|
|
||||||
S,V : String;
|
S,V : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// Writeln('Rendering group headers for row ',aEnum.Index);
|
// Writeln('Rendering group headers for row ',aEnum.Index);
|
||||||
Result:='';
|
Result:='';
|
||||||
StartGroups:=False;
|
// Determine level at which there is a change.
|
||||||
For GrpIdx:=0 to Groups.Count-1 do
|
if aEnum.Index=0 then
|
||||||
|
ChangeIdx:=0
|
||||||
|
else
|
||||||
begin
|
begin
|
||||||
Grp:=Groups[GrpIdx];
|
ChangeIdx:=-1;
|
||||||
aEnum.FGroup:=Grp;
|
GrpIdx:=0;
|
||||||
V:=GetGroupValue(aEnum,GrpIdx,Grp);
|
While (ChangeIdx=-1) and (GrpIdx<Groups.Count) do
|
||||||
if Not StartGroups then
|
|
||||||
StartGroups:=(aEnum.Index=0) or (V<>Grp.FGroupValue);
|
|
||||||
if StartGroups and (aEnum.Index>0) then
|
|
||||||
Result:=Result+RenderGroupFooters(grpIdx,aEnum);
|
|
||||||
Grp.FGroupValue:=V;
|
|
||||||
if StartGroups then
|
|
||||||
begin
|
begin
|
||||||
|
Grp:=Groups[GrpIdx];
|
||||||
|
V:=GetGroupValue(aEnum,GrpIdx,Grp);
|
||||||
|
if (V<>Grp.FGroupValue) then
|
||||||
|
ChangeIdx:=GrpIdx;
|
||||||
|
Inc(GrpIdx);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if ChangeIdx>=0 then
|
||||||
|
begin
|
||||||
|
Grp:=Groups[ChangeIdx];
|
||||||
|
// Writeln('Change at group ', ChangeIdx, ' : ',V,'<>',Grp.FGroupValue);
|
||||||
|
if aEnum.Index>0 then
|
||||||
|
begin
|
||||||
|
// Writeln('Closing footers up to ',GrpIdx);
|
||||||
|
aEnum.FGroup:=Grp;
|
||||||
|
Result:=Result+RenderGroupFooters(ChangeIdx,aEnum);
|
||||||
|
end;
|
||||||
|
for GrpIdx:=ChangeIdx to Groups.Count-1 do
|
||||||
|
begin
|
||||||
|
Grp:=Groups[GrpIdx];
|
||||||
|
V:=GetGroupValue(aEnum,GrpIdx,Grp);
|
||||||
|
Grp.FGroupValue:=V;
|
||||||
|
// Writeln('Group ',Grp.Name, ' header for value ',V);
|
||||||
|
aEnum.FGroup:=Grp;
|
||||||
S:=RenderTemplate(aEnum,Grp.HeaderTemplate);
|
S:=RenderTemplate(aEnum,Grp.HeaderTemplate);
|
||||||
// Writeln('Rendering group ',Grp.Name,' (',V,') header template: ',Grp.HeaderTemplate,' : ',S);
|
// Writeln('Rendering group ',Grp.Name,' (',V,') header template: ',Grp.HeaderTemplate,' : ',S);
|
||||||
Result:=Result+S;
|
Result:=Result+S;
|
||||||
|
Loading…
Reference in New Issue
Block a user