Skip to content

Calculating the subtotals of pages through getCallbackData/renderPageFinished slots may give the wrong value #480

@franfcunha

Description

@franfcunha
  • Calculating the subtotals of pages through getCallbackData/renderPageFinished slots may give the wrong value. An item may request an getCallbackData, which does the sum, but because of sizing/etc that item ends up in the next page. Even using the second pass isn't reliable. It also suffers from the same issues but it's less often, however. The SP uses a dummy Text item inside the row.
  • Sometimes the last item in the horizontal layout inside a DataBand doesn't show up. Its position becomes negative and goes off-screen.
  • I did however find a possible temporary fix. Setting the layout type to 'Table'.

----------------------------------------------------------------------------------DETAILED EXPLANATION-----------------------------------------------------------------------------
1.
With a HorizontalLayout in a DataBand, sometimes, the rightmost item (e.g TextItem) of the first row of a page doesn't render. The position is negative and goes offscreen. If the layoutType is a Table it no longer 'appears' to break.

The subtotals in our report look like this:

Page 1:
# Subtotal of page 1
Page 2:
Subtotal of page 1 Subtotal of page 1 + 2
Page 3:
Subtotal of page 1 + 2 Subtotal of page 1 + 2 + 3

E.g.:
Page 1:
Line 1: 4
Line 2: 1

        0                         5

Page 2:
Line 1: 6

        5                        11

Page 3:
Line 1: 30
Line 2: 8

        11                       49

To calculate it I'm using a FillInSecondPass TextItem, inside the HorizontalLayout rows, that sums the total of page each line "$S{pValorATransportar += Number($D{DS_linhas.total})}".

Then, in the PageFooter, the right TextItem sets the previous total to the current one and displays the current total "pPrevValorATransportar = pValorATransportar; pValorATransportar". The left TextItem of the PageFooter simply displays the "pPrevValorATransportar".

The problem is that sometimes the FillInSecondPass TextItem of the last row of a page is only counted on the next page.
E.g:
Page 1:
Line 1: 1
Line 2: 1
Line 2: 1

        #                         2  <-- Should be 3

Page 2:
Line 1: 1
Line 2: 1

        2                         5

Please find attached a minimal reproducible example of this problem.

ex-page-problem-lr.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions