I have a report which has a dataset. I want to print No Data Band whenever the query in the dataset returns 0 records (empty dataset).
I have set the "When No Data" to "No Data Section". But it doesn't seem to be working.
Any Suggestions?
I have a report which has a dataset. I want to print No Data Band whenever the query in the dataset returns 0 records (empty dataset).
I have set the "When No Data" to "No Data Section". But it doesn't seem to be working.
Any Suggestions?
When I've tried the solution proposed by @Sharad I have found another way, in my approach no need to add No Data band:
The final result will be the same report with no detail. In my case it responds to my needs perfectly.
PS: I used iReport 4.0.2
For those like myself, who do not use JasperSoft or older iReport and directly work with XML, do the following:
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports
http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
whenNoDataType="NoDataSection"
name="freport" pageWidth="595" pageHeight="842"
columnWidth="555" leftMargin="20" rightMargin="20"
topMargin="20" bottomMargin="20">
Add whenNoDataType="NoDataSection"
to the <jasperReport>
element.
<noData>
<band height="15">
<staticText>
<reportElement x="0" y="0" width="200" height="15"/>
<box>
<bottomPen lineWidth="1.0" lineColor="#CCCCCC"/>
</box>
<textElement />
<text><![CDATA[The report has no data]]> </text>
</staticText>
</band>
</noData>
Add <noData>
element below the detail band.
In order to print No data band whenever the query in the dataset returns 0 records(empty dataset) follow these steps:-
After adding No data band whenever query will return 0 record "No Data" band will display the static text.