I want to pass the JRBeancollection datadourse to main report and from main report to subreport.. I have included this subreport in summary section of master report.. please mention the steps i want to do in ireport including the inbuld parameters how to set.
问题:
回答1:
Finally I have done it.
Actually datasource was not going in subreport. So I have changed the property of when no data to all sections, no data...
Then I have passed the collection variable where I have fetched the subreport records.
By using parameters.put("shape_data_all", allShape_Caliberation);
Then I have created a parameter in main report. And changed its class to java.Util.Collection
.
Then in subreport property, connection type=
Use a datasource expression
Data Source Expression new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{shape_data_all})
Then added the fields in the subreport same as I am having the bean properties.
Thank you.
回答2:
I'm not sure, but try this:
<subreport>
<reportElement x="261" y="25" width="200" height="100"/>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "subreport.jasper"]]></subreportExpression>
</subreport>
Of course you have to use the "subreportExpression" as you are doing in your report, this is just a sample, the useful line for your problem is where the "dataSourceExpression" is placed.