[QUESTION] Using an attribute in subreport

0

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.

 

robin.besson1's picture
Joined: Feb 12 2013 - 8:33am
Last seen: 6 years 4 months ago

4 Answers:

0

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

http://www.thomaszimmer.net

Thomas Zimmer's picture
Joined: Oct 2 2012 - 1:35am
Last seen: 5 days 13 hours ago
0

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 :)

robin.besson1's picture
Joined: Feb 12 2013 - 8:33am
Last seen: 6 years 4 months ago
0

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

http://www.thomaszimmer.net

Attachments: 
AttachmentSize
Binary Data master report8.66 KB
Binary Data subreport 13.6 KB
Binary Data subreport 25.22 KB
Thomas Zimmer's picture
Joined: Oct 2 2012 - 1:35am
Last seen: 5 days 13 hours ago
0

Ok I got it, thanks for th detailed explaination :)

robin.besson1's picture
Joined: Feb 12 2013 - 8:33am
Last seen: 6 years 4 months ago
Feedback
randomness