Jump to content
Changes to the Jaspersoft community edition download ×

How to determine which sub-report to show?


2004 IR Help

Recommended Posts

By: Chris - cywong18

How to determine which sub-report to show?

2004-03-31 21:17

Hi all,

 

How to determine which sub-report to show at run time?

 

e.g

At the 1st column:

If the $F{Name} = "ABC"

THEN use sub-report "rpt_ABC"

 

At the 2nd column:

If the $F{Name} = "XYZ"

THEN use sub-report "rpt_XYZ"

 

Would you please tell me how can i do this?

 

Thanks a lot.

Chris

 

 

 

 

By: Rick Millar - rmillar

RE: How to determine which sub-report to show

2004-04-01 08:10

Chris,

 

In one of my reports I have optional subreports that get run based on the value of some parameters. The way I solved the problem was to use the "print when expression" to only print the subreport when the parameter value was correct. You can do the same thing I think for your case. Try to put the following expression in the "print when expression" field of each subreport's property sheet.

 

for rpt_abc:

 

new Boolean( $F{Name}.equalsIgnoreCase("ABC") )

 

rpt_xyz:

 

new Boolean( $F{Name}.equalsIgnoreCase("xyz") )

 

HTH,

 

Rick

 

 

 

 

 

By: C-Box - c-box

RE: How to determine which sub-report to show?

2004-04-16 00:00

Hello Rick & Chris

 

I do have the same problem (I posted it already but just found that thread today).

 

I put already the "print when expression" for each subreport. But when I run the Masterreport that contains one MasterSubReport in which multi SubReports are... always the SubReport is used which fullfilled the first occurrence of my condition... e.g. when value = 1 all the following positions uses the SubReport1... or if the first position has value = 4 then all following positions use SubReport4 .. no matter what value they actually own.

 

What I'm doing wrong?

 

btw, is it correct to use for the MainSubReport that just contains the collection of SubReports each depending with a condition in "print when expression" and for each SubReport the same QueryString?

 

Hope for help

 

C-Box

 

 

 

 

By: C-Box - c-box

RE: How to determine which sub-report to show?

2004-04-20 23:10

Hi again,

 

I solved the problem...

 

it was the wrong query in all the subreports.. I used the same for the MainSubReport and for all SubReports[n]...

 

Correctly it must be a query that just gives one entity from the datasource back - so now I pass the unique primary key to all the subreports that just one entity will be in the resultset.

 

and voilá­ now it works like I wanted.

 

C-Box

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...