views:

24

answers:

2

I have a detail band with potentially a lot of text fields in it. It can get too wide to fit on a page. The result is that it just runs off the edge of the page and you can't see it all. I'd like the detail band to wrap around to another line. Is there any way to do this?

My detail band is built dynamically in the code and the number of fields can vary. I tried manually placing the overflowing fields lower in the band by setting their y values, but then if the text in the fields overflows into two lines, my height calculations are off and the results get really messed up.

So is there any way to constrain the band to fit on the page?

+1  A: 

Perhaps on your reportElement for each field in the band you need to set the attribute stretchType="RelativeToTallestObject".

<reportElement stretchType="RelativeToTallestObject" ...>

I'm pretty sure that's what works for me.

Fly
+1  A: 

Unfortunatelly, the strech types in jasper only works between bands, not within the band.

You can't (even manualy) create a jrxml which will cause a lower element in a band be correctly possitioned when an upper element overflows.

You will need to create more than one detail band. In iReport, you use 'Add another detail band' (on the detail band context-menu). Dynamically, it would look something like:

JRDesignSection detailSection = (JRDesignSection)design.getDetailSection();
JRDesignBand detail2 = new JRDesignBand();
detailSection.addBand(detail2);
yshalbar
I have images in my single detail band as well as text, and I very often have elements in my detail band that overflow, and I think they all get adjusted automatically, but I'll double-check.
Fly