Jump to content

Page Break Only When SubReport Not Empty


Telos

Recommended Posts

Is there a way to reference a property of one report element in the printWhen expression of another? In particular, I want to not have a page break if a certain subreport is blank (the subreport is composed of several elements each with their own printWhen expressions, and I do not want to duplicate all of that logic in one compound statement just for the sake of the page break)

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

That's an interesting idea. Is it possible to return a value that is calculated by Jasper itself (e.g. the height of a band when it is rendered?). If I need to re-evaluate all of the values that control the printWhen expressions for the sub-elements just so I can produce my own return value, then I'm essentially in the same place as I started.

Link to comment
Share on other sites

I resolved the problem in this way:

  • in the master report create a group band
  • put in the group header a Page Break  and the subreport
  • the Page Break.PrintWhen Espression = ($F{createdBy6}==null ? Boolean.FALSE : Boolean.TRUE )
  • The field $F{createdBy6}

Bye

Code:
groupHeader>			<band height="50" isSplitAllowed="false">				<subreport>					<reportElement positionType="Float" x="1" y="24" width="555" height="15" isRemoveLineWhenBlank="true"/>					<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/folder/esameneurologico")]]></dataSourceExpression>					<subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "st_cartella_completa_esameneurologico1.jasper"]]></subreportExpression>				</subreport>				<break>					<reportElement x="0" y="3" width="100" height="1" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" printWhenGroupChanges="esneuro">						<printWhenExpression><![CDATA[($F{createdBy3}==null ? Boolean.FALSE : Boolean.TRUE )]]></printWhenExpression>					</reportElement>				</break>			</band>		</groupHeader>
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...