Stretch a row with data overflow while having multiple rows in a single band
Asked Answered
M

3

21

My requirements bind me to have multiple rows in a single "Details" band.

Right now I am having a static text field (which is highlighted in color) in the leftmost column and three text data fields next to it.

What I want in my report is, the static text band along with the three bands should stretch in height when data in either of the three bands overflows, with the next row "properly" displayed below the stretched row. By "properly" I mean the next row elements should have their "top" values the same and be displayed in the same "row".

I tried setting "Stretch with overflow" flag to "true" and "Position" to "float" but the problem is that the next row data is not properly positioned.

Mischance answered 2/5, 2012 at 11:6 Comment(2)
I have the answer with me but I cannot post it in this comment box, character limit. Neither can I answer it coz I found the answer after 8 hours of asking this question and StackOverflow doesn't allow me. Somebody ask a similar question and I will be able to answer it.Mischance
It's the reverse: you cannot answer within the first 8 hours. Give it a try now.Morlee
M
33

I have found the answer. The key to the solution is grouping the elements inside a row together.

  1. Remove all the static text labels. Use text fields instead, with the text in quotes. They can be grouped with other text fields and data fields.
  2. Put all the data fields after the quoted text field in the same group as the quoted text field.
  3. Now, do the same with all the rows that you want to display. Separate group for individual row.

Select all the elements in a group, or, all the elements in all the gorups and do this:

  • Set "Position" to "Float"
  • Set "Stretch Type" to "Relative to the tallest object"
  • Check "Print when detail overflows" checkbox.
  • Check the "Stretch with overflow" checkbox.

That's all we can do to make things "stretch" together.

Now, the band would have to stretch dynamically with these stretched details. Just go to the band properties, set Split type to "Default" and split allowed to true. This did the trick for me.

Mischance answered 4/5, 2012 at 8:31 Comment(3)
I'm having the same problem that I mentioned here link. In my case I want to style the labels differently e.g. bold labels. If I put static text along with the field like "Name: "+F{name} then how can I format the label separately. Also, can you please show us a few screenshots of how did you actually group the elements? ThanksCoo
@Ali, Sorry, man, I don't have access to Jasper now, but I believe this can be done through Properties box. It has to be very easy, as even in my case up in here I had made the labels bold. I didn't mention that in these posts as it was too easy and obvious.Mischance
I had column headers that were not having the same height across the header row. The solution was to add astretchType="RelativeToBandHeight" attribute to each <reportElement> tag inside my <textField>s which were all enclosed by the <band height="15" splitType="Stretch"> tag.Clathrate
L
4

In case someone comes up to this problem and above answers don't work. I suggest checking your xml's root element. If it has the following attribute then remove it:

printOrder="Horizontal"

Then above answers should work.

Hope I'll save someone a day of googling the same stuff.

Lindbom answered 3/11, 2015 at 13:54 Comment(0)
C
3

In my case doing as you advised didn't work. I had to modify your solution a little bit - I made a "frame" instead of grouping objects, and put previuosly grouped elements in that frame. I set positionType="Float" and stretchType="No stretch" in that frame, and set stretchType="RelativeToTallestObject" to its child items - then it all works.

Cracksman answered 14/1, 2014 at 11:54 Comment(2)
Thanks for the answer. If you add your version of JasperServer and other important details it would be better for everyone here.Mischance
Of course: Product version: Jaspersoft iReport Designer 5.5.0; Java: 1.7.0; Java HotSpot(TM) 64-Bit Server VM 21.0-b17; System: Windows 7 ver. 6.1 working on amd64; Cp1250; pl_PL (ireport); I guess that's all...Cracksman

© 2022 - 2024 — McMap. All rights reserved.