Good morning everyone, I have been facing a problem on iReport 4.6.0.
What I would like to do is use an attribute that's in my report's Detail section in a subreport which is also in the detail section of my report. So that I can retrieve datas in my subreport according to the value of my attribute in the nesting report. (By attribute I mean a field from my query in my nesting report)
I anyone has any idea how to work this out, it would be great !
Cheers.
4 Answers:
Check the setting of your subreport element, there is an option "Parameters". Her you can set an expression which is passed into a Parameter of your subreport. The expression can be a literal, variable, field or anything else of your main report. The Parameter in the subreport then can be used in the subreport´s query or elsewhere...
you have a similar functionality for returning values from your subreport into the main report...
check the examples in iReport "Help > Samples > Subreport"
Cheers, Thomas
Thanks for your answer Thomas,
But I am kind of lost in all this, I don't know how to pass the parameter from my master report to the subreport.
I checked the 'Subreport' example, and the fact that using the different values of 'shipcountry' in the subreport is exactly what I want to do, but I cannot figure out how it is done.
If you can help me with that I would be gratefull :)
just click on the subreport element in the visual representation of your report. Then search the setting "Parameters" in the "roperties-View (you can de-/activate via the menue)
finally set a parameter-pass:
"Subreport parameter name" must be an existing parameter in your subreport, "Value expression" ca be anything, a parameter, variable or field (as described earlier) or just a static string.
I attached the sample reports her again, because in my iReport installation only one of the subreports opens; either i crashed this or it comes like this within the installation (that would not be nice...).
In the example "master" report, you can see that the field $F{SHIPCOUNTRY} is passed to the subreports. In the subreports the parameter is used in the queries, for example: select * from orders where shipcountry = $P{shipcountry}
I hope this helps.
Cheers, Thomas
Attachment | Size |
---|---|
![]() | 8.66 KB |
![]() | 3.6 KB |
![]() | 5.22 KB |