Tarek
Tarek

Reputation: 3798

Global variable in iReport - Jasper subReports

Anyone know if we can set a global variables in a main report and have the sub-reports use those variables ?

In my case i have a very complicated report (Main report and then few sub-reports then in those sub-reports...other sub-sub-reports (3-5 levels like that).

Now it came to my attention that i need to pass a new variable from user input and this variable need to be used by multiple sub reports .

I know i can pass variables from Main to sub to other subs but this is a long process which i'm trying to avoid .

Any ideas ?

Thanks for the help!

Upvotes: 2

Views: 4056

Answers (1)

Ismail Sahin
Ismail Sahin

Reputation: 2710

In your main report create a paramter; lets say it's $P{main_parameter}

In a subreport create another paramter to handle $P{main_parameter}'s value; let it be $P{subreport_parameter}

now in mainreport you have $P{main_parameter}

and in subreport you have $P{subreport_parameter}

finaly; in your mainreport right click on the subreport ->paramters -> add. That's it. Now you can pass parameter from main report to subreport.

enter image description here

Not: be careful both paramters' type should be same otherwise you will get error

Upvotes: 2

Related Questions