Jump to content
We've recently updated our Privacy Statement, available here ×

Each row of subreport corresponding with row of main report


i.zigi

Recommended Posts

Hello,

I have main report with data source, which returns more then one row. 

ID: 1, name: xxx, adress: yyy

ID: 2, name: zzz, adress: aaa

...

then I have subreport with data source, which also returns more then one row.

ID: 1, product: bbb

ID: 2, product: ccc

...

I need connect in report both information together always in one detail. So in one page will be information: 1, name: xxx, adress: yyy + 1, product: bbb, and second page will be 2, name: zzz, adress: aaa + 2, product: ccc.

Now jasper generate report like this: 1, name: xxx, adress: yyy + 1, product: bbb, in next page only 2, product: ccc, and last page only 2, name: zzz, adress: aaa + empty subreport.

I have group on detail in main report on ID. I tried pass parametr to subreport, but nothings work.

Thank for any helps

Ivo

<pre data-fulltext="" data-placeholder="Překlad" dir="ltr" id="tw-target-text">  </pre>

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

In your main report you have to have a parameter set for each subreport.  This is kind of confusing because there are two different types of parameters.  In Outline | Parameters, these are the parameters that come IN to the master report.  In Outline | Title | Subreport | Subreport click the "Edit Parameters" button to set up parameters that come from your master report and are given to the sub report.  For example I have added a parameter Named ID with Expression $F{ID} .  This gets the ID from my master report and passes it to the name "ID" in my sub-report.  Then in the sub-report you use this parameter in a WHERE clause like: WHERE ID = $P{ID}   This selects only sub-report records that match the primary report records.  So when the master report is run it loops thru it's data source getting each record one at a time.  It passes the ID to the sub-reports.  The each sub report returns just the records for that record. 

Tip:  1) You must save your sub-reports (with ^S or File | Save) after editing them, and before running the master report!  Otherwise any edits to them won't be seen by the master report.



Hope this helps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...