Jump to content

hiding subreport


ummekulsum4321

Recommended Posts

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

You can use printWhenExpression to show/hide your subreport.

<subreport>    <reportElement x="26" y="14" width="190" height="17" uuid="285bfacd-4092-4d3a-ac1f-6d72074350ae">       <property name="com.jaspersoft.studio.unit.width" value="px"/>       <property name="com.jaspersoft.studio.element.name" value="mySubreport"/>       <printWhenExpression><![CDATA[$P{checkoutPointItems} == null || $P{checkoutPointItems}.isEmpty()]]></printWhenExpression>    </reportElement>    <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{checkoutPointItems})]]></dataSourceExpression>    <subreportExpression><![CDATA["templates/pdf/subreports/checkout-point-item.jasper"]]></subreportExpression></subreport>[/code]

 

Link to comment
Share on other sites

If you know ahead of time that you want to suppress a band or subreport then @IAmLeo is correct that you can pre-emptively suppress it using the print when expression, either on the band or the subreport depending on your layout.

If you want to suppress the subreport only if there is no data then I think what you need to do is set the "When No Data Type" field to "No Data Section" and make that section really small.

Another option (I haven't tried this yet) would be to pass back a record count from the subreport using the Edit Return Values and see if you can suppress based on the return value.  Like I said I haven't tried that yet.  The "No Data Section" in the subreport has always worked well for me.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...