create empty main report with multiple existing sub reports with different dataset

 I want to create an empty main report with no dataset and no query in Jasper Studio to display existing reports as multiple sub reports in it. The main report should just act as a container to display multiple sub reports. Sub reports are charts having seperate datasets . How do I proceed?

vanjaxi.sm's picture
Joined: Dec 17 2015 - 1:41am
Last seen: 7 years 6 months ago

@javier  I created main report with empty dataset. Created a new sub report within main report in summary band which is a chart .

In the sub report property in main report added Expression: "subreport1.jrxml" and connection expression comes as $P{REPORT_CONNECTION}

I can view the subreport but when I run the main report the report is blank page/ Document is empty in Jasper soft Studio.

 

vanjaxi.sm - 7 years 7 months ago

I remember something like that happened to me and I solved it adding a query into the main report. That is why I suggested step one from my answer so that you do not have to bring any data from the data source and don't affect performance.

Also, using $P{REPORT_CONNECTION} means you will use the datasource from the main report in the subreport. If that is what you intend, by all means leave it like that.

javier.ggi90 - 7 years 7 months ago

Another thing that might be affecting is if you are not mapping the parameters from the main report into the subreport which would cause the subreport to be blank. To do this you need to create the parameter in the main report and then in the subreport properties look for the "parameters" option and map them there.

javier.ggi90 - 7 years 7 months ago
show 1 more...

I nailed it. Thanks @javier to read through my ques and supporting. It helped.

I found no need to map parameter or a qery to main report, though I tried all of the possibilities. Ofcourse used parameter {Report _Connection }.The problem lied with  Data type in Main report properties where  for Report - When no Data Type to set to All sections No Detail.

Can you help me with Alignment of sub reports ??

 

vanjaxi.sm - 7 years 7 months ago

2 Answers:

You can try the following:

  1. In the main report query: "SELECT 1"/"SELECT 1 FROM DUAL"/what ever in the language you are using
  2. Create the subreports and in their properties change the Connection Type property to 'Use a connection expression'
  3. In the Connection Expression property open a new connection to your datasource, for example if MySQL (NOTE: the following are two different examples because iReport and JasperServer function different and as so need different expressions. If you are testing in iReport use the first expression, if testing in JasperServer use the second one):
    • com.jaspersoft.ireport.designer.utils.Misc.getConnection("{Data Source Name}")
    • java.sql.DriverManager.getConnection("jdbc:mysql://hostname:3306/dbname","user","password")

Repeat step 3 for each subreport you are using.

javier.ggi90's picture
Joined: Dec 6 2015 - 1:46pm
Last seen: 6 years 5 months ago

Mapping the parameters of the main report and subreport is a necessary step. 
The logic behind this is that the input controls would exist for the main report and will be fetching data for the parameters of the main report and these values needs to be passed on to the subreports for fetching data.
For mapping the main report and subreport parameters, you need to make sure all the sub report parameters exist in main report parameters. 


Regards,
KKriplani

kkriplani's picture
5774
Joined: Sep 4 2015 - 2:18am
Last seen: 1 year 5 months ago
Feedback
randomness