I have ran into 2 situations already that feel like they could be solved if JasperReports had some kind of JRDesignElementGroup. I’ve checked the net.sf.jasperreports.engine.design. package high and low but can’t find anything like it, although I was able to find a JRDesignGroup which looks like it sort of accomplishes what I’m looking for, but I’m not very sure of that.
Here are the siutations where my issue is cropping up:
(1) Grouping multiple text fields together:
I’d like to have a report where I can print out the names and values of a bunch of metrics; something that looks like:
Name: John Smith
Email: john.smith@example.com
I was hoping to accomplish this by creating 1 JRDesignElement subclass instance, and adding it to a band in my JasperDesign object. However, after thinking it over, that setup requires 3 separate JRDesignElements: 2 JRDesignTextFields (for the metric name and value) and 1 JRDesignStaticText for the colon (“:”) and space between them.
Is there a way to append these 3 items to a group and then just add the group to a band?
(2) Group an image and its title/caption
I also would like to do the same as above, except using JRDesignImage and JRDesignStaticText elements, where the image is an image to be displayed on my report, and the static text will be a title or caption to be placed above the image.
Is there any way to append these 2 items to a group and then just add the group to a band?
If so, can anyone provide JRXML, or even more preferably, some Java examples for how to do this appending? And if not, what’s the solution/work-around?
Thanks in advance!
JRDesignTextFieldelementJRDesignStaticTextand twoJRDesignTextFieldelements togetherUsing three
JRDesignImageand singleJRDesignStaticTextelements