Thursday, May 20, 2010

List Collection Data Not visible in mainreport of subreport - iReport


I have been wondering How iReport takes care of subreport I faced all above problem doing subreport in iReport.

In order to pass List / collection to subreport following things need to be done....

In Main Report. >>>>>>>>>>>>>>>>> Put Following

<import value="net.sf.jasperreports.engine.*"/>
<import value="*"/>

//Define List

<field name="addresses" class="java.util.List"/>

Pass List to subreport

<subreport isUsingCache="true">
<reportElement x="0" y="39" width="555" height="276"/>
<subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} "report1_subreport5.jasper"]]></subreportExpression>

In Subreport >>>>>>>>>>>>>>>>> put Following

very important >>> below address is field in my addressess List in Main Report

<field name="address" class="java.lang.String"/>

and In Detail Section Put Following

<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="142" y="20" width="92" height="20"/>
<font size="12"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{address}]]></textFieldExpression>

Remeber Many time you might not see subreport visible in main report reson being it the Property for Data to visible >>

"When No Data "(Property of report) should be set accordingly.

Hope this might help some one....


No comments:

Post a Comment