My main report contains 5 fields, 4 of them are of type java.lang.String and the last one is of type java.util.List. I used its latter as the data source for the subreport. I set the datasource of the subreport.
Subreport properties:
Connection Type : Use a datasource expression
Datasource Expression : new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{Field5})
Passing of data is working fine (I guess) because when I fill the report inside the Java application. I can view the data passed to fields 1 to 4 but in field 5, at first, I can't verify because the subreport does not show data, only the static texts defined in the Column Header.
Then when I placed the fields of the subreport in the Page Footer, I found out that the data is passed successfully, the problem is that the Detail band itself is not showing.
Why is it not showing?
In the subreport properties, I have:
When no data: All Sections, No Detail
Please can anyone shed some light on this.
A subreport is a report included inside another report. This allows the creation of very complex layouts with different portions of a single document filled using different data sources and reports.
If you are using iReport to create reports then open the main report in iReport and select Subreport and go to the property section of the report, click on Parameters property and click on Copy from master tab. From there you can select the parameters which you want to pass to the sub report.
In the Navigation Pane, right-click the report to which you want to add a subreport, and then click Design View. In the menu that appears, ensure that Use Control Wizards is selected. Open the Controls Gallery again, and then click Subform/Subreport. On the report, click where you want to place the subreport.
I had the same problem for more than 1 day. In the application I am developing on there are multiple JasperReports which work. I encountered this problem when adding a new one. No matter what I tried, nothing displayed in the Detail band. I tried everything from triple-checking the Controller that populates the report, to upgrading to the latest jasperreports
jar and latest iReports
version. Nothing seemed to work.
The problem is that the report is set by default to: When No Data: All Sections, No Detail
, which basically means that if no data is sent to the report, it will display all sections, except for the Detail one.
Although besides static text which I was using to test the report I was passing parameters directly from the Java Controller, it did not work until I added an EXEC [myFunction] $P{parameterId}
to the Query Text property of the report. The function is a simple straightforward one, which takes a parameterId
passed from Java as a parameter and returns something. (also, make sure you set the The language for the dataset query sql property to SQL).
To sum up, for some reason the report doesn't seem to take the Java parameters as data (so it displays all the sections, except for Detail), so when I explicitly call a SQL function which returns some parameters and put them into my detail page, it works.
I hope this helps you, I busted my head for 10 hours to figure this out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With