Browse Source

* Reset aggregates only after child bands are printed. Patch by by Dokkie8844. Fixes issue #41294

Michaël Van Canneyt 5 days ago
parent
commit
1973f07aad
1 changed files with 18 additions and 11 deletions
  1. 18 11
      packages/fcl-report/src/fpreport.pp

+ 18 - 11
packages/fcl-report/src/fpreport.pp

@@ -9546,17 +9546,8 @@ begin
 end;
 end;
 
 
 procedure TFPReportCustomBand.AfterPrintBand(pBand: TFPReportCustomBand);
 procedure TFPReportCustomBand.AfterPrintBand(pBand: TFPReportCustomBand);
-var
-  i: integer;
-  c: TFPReportElement;
 begin
 begin
-  // reset aggregates after printing
-  for i := 0 to ChildCount - 1 do
-  begin
-    c := Child[i];
-    if c is TFPReportMemo then
-      TFPReportMemo(c).ResetAggregates; // checks for moNoResetAggregateOnPrint
-  end;
+  // Do nothing
 end;
 end;
 
 
 procedure TFPReportCustomBand.BeforePrintWithChilds;
 procedure TFPReportCustomBand.BeforePrintWithChilds;
@@ -9570,8 +9561,24 @@ begin
 end;
 end;
 
 
 procedure TFPReportCustomBand.AfterPrintWithChilds;
 procedure TFPReportCustomBand.AfterPrintWithChilds;
+var
+  i: integer;
+  c: TFPReportElement;
+  lBand: TFPReportCustomBand;
 begin
 begin
-  // Do nothing
+  // reset aggregates after printing
+
+  lBand := Self;
+  while Assigned(lBand) do
+  begin
+    for i := 0 to lBand.ChildCount - 1 do
+    begin
+      c := lBand.Child[i];
+      if c is TFPReportMemo then
+        TFPReportMemo(c).ResetAggregates; // checks for moNoResetAggregateOnPrint
+    end;
+    lBand := lBand.ChildBand;
+  end;
 end;
 end;
 
 
 constructor TFPReportCustomBand.Create(AOwner: TComponent);
 constructor TFPReportCustomBand.Create(AOwner: TComponent);