Jump to content
Changes to the Jaspersoft community edition download ×

Multiple Subreports Will Not Display


Recommended Posts

By: Bill Fritz - bfritz2

Multiple Subreports Will Not Display

2002-12-10 12:37

I submitted an incorrect xml on My Report Desin Question thread, I am restaing it here:

I am having trouble displaying subreports. The Master Report contains varying numbers of subreports each with its own datasource. There are two categories od subreports: 1) Plots - which only display an image; each plot/subreport should start on a new page and 2) Tables which can span multiple pages. There can be as many as 5-10 plots and a similar number of tables. IDo I use dummy droups to display these subreports and if so, one dummy group per subreport, or do I stuff all subreports into a summary section? I also am perplexed as to the guidelines of band height vs reportElement height for a subreport.

 

For example if I have a summary section, what should its band height be relative to its subreport reportElement heights? Her's an example of what I'm talking about. Can you do this? It doesn't seem to work. Does the Master report's band/subreport reportElement attributes: x, y, width, and height have to match what is actually specified in the Subreport.xml??? I don't know how Jasper Reports figures this all out, so am at a loss to get this working. By the way, thanks for all the help so far!!!

 

Bill

 

<summary>

<band height="60">

<subreport>

<reportElement x="0" y="0" width="515" height="20"/>

<subreportParameter name="Plot1Title">

<subreportParameterExpression>

$P{Plot1Title}

</subreportParameterExpression>

</subreportParameter>

<subreportParameter name="Plot1Image">

<subreportParameterExpression>

$P{Plot1Image}

</subreportParameterExpression>

</subreportParameter>

<dataSourceExpression>

new dori.jasper.engine.JREmptyDataSource()

</dataSourceExpression>

<subreportExpression class="java.lang.String">

"Plot1.jasper"

</subreportExpression>

</subreport>

<subreport>

<reportElement x="0" y="30" width="515" height="20"/>

<subreportParameter name="Plot1Title">

<subreportParameterExpression>

$P{Plot2Title}

</subreportParameterExpression>

</subreportParameter>

<subreportParameter name="Plot1Image">

<subreportParameterExpression>

$P{Plot2Image}

</subreportParameterExpression>

</subreportParameter>

<dataSourceExpression>

new dori.jasper.engine.JREmptyDataSource()

</dataSourceExpression>

<subreportExpression class="java.lang.String">

"Plot=2.jasper"

</subreportExpression>

</subreport>

</band>

</summary>

 

 

 

 

By: Teodor Danciu - teodord

RE: Multiple Subreports Will Not Display

2002-12-11 03:19

 

Hi,

 

Both solutions are correct.

 

The height of the subreport element represents

in fact its minimal height. This is because subreport

will almost certainly stretch. But their original height

is the minimum amont of space that they will surely

use from the band.

 

Lets say you have 5 subreports.

You could place all of them in one band (the summary of the master for example).

If each subreport has an original height of 20 and

there is no space between them, your fifth subreport

should be placed at y="80".

The problem with this approach is that when the

summary will overflow, the fifth subreport will overflow,

the engine will first try to place it at y=80 on the new page, will evaluate the space remaining until

the bottom of the page and only after will eliminate

the unused 80 pixels from the top of the page.

This means that you will surely get 80 pixels of unused space at the bottom of your fifth subreport.

See ?

To eliminate this 80 pixels high space at the bottom

of the page, you could make your subreports of height ="0" (they will stretch anyway) and place one

after the other, the next one pixel above the previous.

In this scenario, the fifth subreport will be placed at

y="4" and when it will overflow, the unwanted blank space at the end will be only 4 pixels high.

 

And now the other approach.

Make a dummy group for each subreport that you want to display. If you do so, you'll never have

problems with some white space left at the bottom

of your pages. And the height of the subreport does not matter, as I previously said. The band height

should exactly match the height of the subreport,

if you don't want to have extraspace between

subreports.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...