Note that there are some explanatory texts on larger screens.

plurals
  1. POJasper server subreport in detail band
    text
    copied!<p>I need to create subreports in detail band, i am passing same datasource of main report to subreports. Issue i am facing as it goes in to subreport it increments the index counter which does not allow to add remaining subreport.</p> <p><i>MainReport.jrxml</i></p> <pre><code>&lt;group name="Account Summary"&gt; &lt;groupHeader&gt; &lt;band height="100" splitType="Stretch"&gt; &lt;printWhenExpression&gt;&lt;![CDATA[$F{accountSummary.hasRepots}]]&gt;&lt;/printWhenExpression&gt; &lt;subreport isUsingCache="false"&gt; &lt;reportElement x="28" y="0" width="540" height="100" isRemoveLineWhenBlank="true"/&gt; &lt;subreportParameter name="accountSummary"&gt; &lt;subreportParameterExpression&gt;&lt;![CDATA[$F{accountSummary.hasRepots}]]&gt;&lt;/subreportParameterExpression&gt; &lt;/subreportParameter&gt; &lt;dataSourceExpression&gt;&lt;![CDATA[$P{REPORT_DATA_SOURCE}]]&gt;&lt;/dataSourceExpression&gt; &lt;subreportExpression&gt;&lt;![CDATA[$P{SUBREPORT_DIR} + "SubReport.jasper"]]&gt;&lt;/subreportExpression&gt; &lt;/subreport&gt; &lt;/band&gt; &lt;/groupHeader&gt; &lt;/group&gt; </code></pre> <p><i>SubReport.jrxml</i></p> <pre><code>&lt;detail&gt; &lt;band height="100" splitType="Stretch"&gt; &lt;subreport isUsingCache="false"&gt; &lt;reportElement positionType="Float" x="0" y="0" width="540" height="100" isRemoveLineWhenBlank="true"/&gt; &lt;dataSourceExpression&gt;&lt;![CDATA[$P{REPORT_DATA_SOURCE}]]&gt;&lt;/dataSourceExpression&gt; &lt;subreportExpression&gt;&lt;![CDATA[$P{SUBREPORT_DIR} + $F{subreportFileName}]]&gt;&lt;/subreportExpression&gt; &lt;/subreport&gt; &lt;/band&gt; &lt;/detail&gt; </code></pre> <p>Where i pass $F{subreportFileName} from my datasource for example "SubSubReport.jrxml", but it only displays first report, i guess due to my index counter runs out in my sub-sub report so my sub report detail band doesn't go for each element.</p> <p><i>SubSubReport.jrxml</i></p> <pre><code>&lt;field name="chartData.label" class="java.lang.String"/&gt; &lt;field name="chartData.value" class="java.lang.Float"/&gt; &lt;field name="value1" class="java.lang.String"/&gt; &lt;field name="value2" class="java.lang.String"/&gt; &lt;field name="value3" class="java.lang.String"/&gt; &lt;pageHeader&gt; &lt;band height="114" splitType="Stretch"&gt; &lt;staticText&gt; &lt;reportElement style="lbl-light-golden" x="12" y="19" width="170" height="67"/&gt; &lt;textElement&gt; &lt;font size="26"/&gt; &lt;/textElement&gt; &lt;text&gt;&lt;![CDATA[Some Label]]&gt;&lt;/text&gt; &lt;/staticText&gt; &lt;pieChart&gt; &lt;chart evaluationTime="Band"&gt; &lt;reportElement x="272" y="0" width="268" height="114"/&gt; &lt;chartTitle/&gt; &lt;chartSubtitle/&gt; &lt;chartLegend position="Left"/&gt; &lt;/chart&gt; &lt;pieDataset&gt; &lt;keyExpression&gt;&lt;![CDATA[$F{chartData.label}]]&gt;&lt;/keyExpression&gt; &lt;valueExpression&gt;&lt;![CDATA[$F{chartData.value}]]&gt;&lt;/valueExpression&gt; &lt;labelExpression&gt;&lt;![CDATA[null]]&gt;&lt;/labelExpression&gt; &lt;/pieDataset&gt; &lt;piePlot isShowLabels="false" isCircular="true"&gt; &lt;plot/&gt; &lt;itemLabel/&gt; &lt;/piePlot&gt; &lt;/pieChart&gt; &lt;/band&gt; &lt;/pageHeader&gt; &lt;columnHeader&gt; &lt;band height="18" splitType="Stretch"&gt; &lt;line&gt; &lt;reportElement x="0" y="1" width="540" height="1"/&gt; &lt;/line&gt; &lt;staticText&gt; &lt;reportElement style="lbl-black-table-header" x="12" y="4" width="158" height="14"/&gt; &lt;textElement/&gt; &lt;text&gt;&lt;![CDATA[Header 1]]&gt;&lt;/text&gt; &lt;/staticText&gt; &lt;staticText&gt; &lt;reportElement style="lbl-black-table-header" x="205" y="4" width="199" height="14"/&gt; &lt;textElement textAlignment="Right"/&gt; &lt;text&gt;&lt;![CDATA[Header 2]]&gt;&lt;/text&gt; &lt;/staticText&gt; &lt;staticText&gt; &lt;reportElement style="lbl-black-table-header" x="445" y="4" width="74" height="13"/&gt; &lt;textElement textAlignment="Center"/&gt; &lt;text&gt;&lt;![CDATA[Header 3]]&gt;&lt;/text&gt; &lt;/staticText&gt; &lt;line&gt; &lt;reportElement x="0" y="17" width="540" height="1"/&gt; &lt;/line&gt; &lt;/band&gt; &lt;/columnHeader&gt; &lt;detail&gt; &lt;band height="18" splitType="Stretch"&gt; &lt;textField isStretchWithOverflow="true"&gt; &lt;reportElement positionType="Float" x="12" y="1" width="158" height="16"/&gt; &lt;textElement/&gt; &lt;textFieldExpression&gt;&lt;![CDATA[$F{value1}]]&gt;&lt;/textFieldExpression&gt; &lt;/textField&gt; &lt;textField isStretchWithOverflow="true"&gt; &lt;reportElement positionType="Float" x="205" y="1" width="199" height="16"/&gt; &lt;textElement textAlignment="Right"&gt; &lt;font isStrikeThrough="false"/&gt; &lt;/textElement&gt; &lt;textFieldExpression&gt;&lt;![CDATA[$F{value2}]]&gt;&lt;/textFieldExpression&gt; &lt;/textField&gt; &lt;textField isStretchWithOverflow="true"&gt; &lt;reportElement positionType="Float" x="445" y="1" width="74" height="16"/&gt; &lt;textElement textAlignment="Right"/&gt; &lt;textFieldExpression&gt;&lt;![CDATA[$F{value3}]]&gt;&lt;/textFieldExpression&gt; &lt;/textField&gt; &lt;/band&gt; &lt;/detail&gt; </code></pre> <p>Also i tried using Groups instead of detail band as follows in "SubReport.jrxml"</p> <p><i>SubReport.jrxml</i></p> <pre><code>&lt;group name="Sub report 1"&gt; &lt;groupHeader&gt; &lt;band height="100" splitType="Stretch"&gt; &lt;subreport isUsingCache="false"&gt; &lt;reportElement positionType="Float" x="0" y="0" width="540" height="100" isRemoveLineWhenBlank="true"/&gt; &lt;dataSourceExpression&gt;&lt;![CDATA[$P{REPORT_DATA_SOURCE}]]&gt;&lt;/dataSourceExpression&gt; &lt;subreportExpression&gt;&lt;![CDATA[$P{SUBREPORT_DIR} + "SubSubReport.jasper"]]&gt;&lt;/subreportExpression&gt; &lt;/subreport&gt; &lt;/band&gt; &lt;/groupHeader&gt; &lt;/group&gt; &lt;group name="Sub report 2"&gt; &lt;groupHeader&gt; &lt;band height="200" splitType="Stretch"&gt; &lt;staticText&gt; &lt;reportElement x="110" y="10" width="100" height="20"/&gt; &lt;textElement/&gt; &lt;text&gt;&lt;![CDATA[Sub report 2]]&gt;&lt;/text&gt; &lt;/staticText&gt; &lt;subreport isUsingCache="false"&gt; &lt;reportElement positionType="Float" x="0" y="40" width="540" height="100" isRemoveLineWhenBlank="true"/&gt; &lt;dataSourceExpression&gt;&lt;![CDATA[$P{REPORT_DATA_SOURCE}]]&gt;&lt;/dataSourceExpression&gt; &lt;subreportExpression&gt;&lt;![CDATA[$P{SUBREPORT_DIR} + "SubSubReport1.jasper"]]&gt;&lt;/subreportExpression&gt; &lt;/subreport&gt; &lt;/band&gt; &lt;/groupHeader&gt; &lt;/group&gt; </code></pre> <p>It prints "Sub report 2" label but no success with printing "SubSubReport1.jasper"</p> <p>What am i doing wrong any suggestions or any direction which can help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload