Jump to content
Changes to the Jaspersoft community edition download ×

Loading subreport based on a parameter


naresh.kabra_1

Recommended Posts

Hi..I have a main report which internally calls three sub report. I have one parameter and based on the valye of teh parameter I need to show only one sub report and need to hide remaning two report.

I have added thre detailed band and in each detailed band I have added the three sub reports.

I can use print when expression for the hiding of the band ..but can some one please suggest how this pront when expression works. will all the sub report hit the databse and fetch the records and at run time Jasper will disbale the remaning two sub reports which are in the detailed band which need to be hide.

 

What is the bease way to write conditional query in Jaspper..we are using styudio 6.3.0. Can some one please suggest..

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

The print when needs to return a boolean.

For example, insert this expression into the print when expression  ($P{Parameter}.equals("first")) == true

In order to stop the unwanted queries hitting the database, you can create a parameter based on your main parameter and limit the no of rows on your sql in three datasets.

I would write my 3 sqls as:

1) select * from dual where $P{Parameter} = 'first'

2) select * from dual where $P{Parameter} = 'Second'

3) select * from dual where $P{Parameter} = 'third'

For example, i only want the first subreport to showup on the report,

then i would pass 'first' into the parameter, which enables the first dataset and returns rows. the second and third dataset would not execute as the condition did not pass.

Link to comment
Share on other sites

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