20

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.

Alex K
  • 22,315
  • 19
  • 108
  • 236
Rachcha
  • 8,486
  • 8
  • 48
  • 70
  • 1
    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. – Rachcha May 02 '12 at 16:11
  • 1
    It's the reverse: you cannot answer within the first 8 hours. Give it a try now. – mdahlman May 02 '12 at 22:30

3 Answers3

31

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.

Rachcha
  • 8,486
  • 8
  • 48
  • 70
  • I'm having the same problem that I mentioned here [link](http://stackoverflow.com/questions/18599795/jasper-reports-align-dynamic-text-fields-and-their-labels-horizontally). 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? Thanks – Ali Sep 04 '13 at 07:18
  • 1
    @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. – Rachcha Sep 04 '13 at 07:23
  • I had column headers that were not having the same height across the header row. The solution was to add a`stretchType="RelativeToBandHeight"` attribute to each `` tag inside my ``s which were all enclosed by the `` tag. – Pierre C Aug 29 '19 at 17:29
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.

Karolis.sh
  • 1,618
  • 20
  • 20
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.

murison
  • 3,640
  • 2
  • 23
  • 36
  • Thanks for the answer. If you add your version of JasperServer and other important details it would be better for everyone here. – Rachcha Jan 14 '14 at 12:35
  • 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... – murison Jan 14 '14 at 13:45