Transfer values ​​from the main report to the subreport?

I just started working with iReport and got the task to make some changes to existing reports.

Currently, there is a main report with sections A and B (contact details and other information). There is a sub-report C, and then a sub-registry D. My task is to replicate A and B for each item in D. If the report has many sections D, I want to have A and B for each.

All data is in one XML document and to get data for sections A and B I just

((net.sf.jasperreports.engine.data.JRXmlDataSource)$F{REPORT_DATA_SOURCE}).dataSource("/Header/")

and for an additional report with section D

((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/Header/ProductHeader/Member")

if I drag a field from the document structure that displays the data in section A to section D and validates the expression that it says $ F {ContactNumber} but displays Null in D, even if it displays the value in section A

How do I change my data sources to display the contents of A and B in D?

Thanks in advance

+3
source share
1 answer

You need to pass the parameters to your subsection. The subreport does not transmit any data from your main report unless you explicitly define a contract. This is more a method call than a continuation of the main report.

If you want to display the field with the name fooin your main report in a subreport, you will need to do the following:

  • Create a parameter in your sub-report with the name foo.
  • Create a subresource element in your main report.
  • - "". foo .

foo -, : $P{foo}, .

+9

Source: https://habr.com/ru/post/1793781/


All Articles