jasperReport/iReport subreport shows blank (not displayed)


Place your sub-report field in the any other band other than detail band and add whenNoDataType="AllSectionsNoDetail" to your xml file.
Add it among the other report properties in <JasperReport> tag.
You can also add using the GUI Designer.
Open your sub report and in the properties editor, at the end of the options you will find
When No Data option. Select All Sections with No Detail from the list of available options.


Mainreport :

<?xml version="1.0" encoding="UTF-8"?>
<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" name="report1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="12"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA["/home/qualian/Desktop/gopi/prjreport/"]]></defaultValueExpression>
</parameter>
<queryString>
    <![CDATA[]]>
</queryString>
<background>
    <band splitType="Stretch"/>
</background>
<title>
    <band height="79" splitType="Stretch"/>
</title>
<pageHeader>
    <band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
    <band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
    <band height="125" splitType="Stretch">
        <subreport>
            <reportElement x="33" y="56" width="208" height="36"/>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR}+"report3_subreport1.jasper"]]></subreportExpression>
        </subreport>
        <staticText>
            <reportElement x="33" y="15" width="100" height="20"/>
            <textElement/>
            <text><![CDATA[Main Report]]></text>
        </staticText>
    </band>
</detail>
<columnFooter>
    <band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
    <band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
    <band height="42" splitType="Stretch"/>
</summary>


Sub report:

<?xml version="1.0" encoding="UTF-8"?>
<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" name="report1_subreport3" language="groovy" pageWidth="555" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<background>
    <band splitType="Stretch"/>
</background>
<columnHeader>
    <band height="40" splitType="Stretch">
        <staticText>
            <reportElement x="107" y="12" width="100" height="20"/>
            <textElement/>
            <text><![CDATA[Sub Report]]></text>
        </staticText>
    </band>
</columnHeader>


This worked like a charm. Hope this helps.


Above issue got resolved using below tag which I had included in my mainreport. We need to use empty data source (new net.sf.jasperreports.engine.JREmptyDataSource())

SUBREPORT.jrxml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using     JasperReports Library version 6.3.1  -->
<!-- 2016-12-15T10:33:58 -->
<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" name="HYPERLINKS_SUBREPORT" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="ad9606b1-969d-4340-a7eb-61dc30ec8f0d">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<queryString>
    <![CDATA[]]>
</queryString>
<detail>
    <band height="82" splitType="Stretch">
        <staticText>
            <reportElement x="16" y="47" width="100" height="30" uuid="866e60e7-16a0-4fea-b56f-ca4143e98fec"/>
            <text><![CDATA[Testing text]]></text>
        </staticText>
    </band>
</detail>

XML of main_report.jrxml

        <subreport>
            <reportElement positionType="Float" x="0" y="220" width="200" height="60" uuid="62463158-73b1-4089-b66c-633d3a987649"/>
            <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
            <subreportExpression><![CDATA["SUBREPORT.jasper"]]></subreportExpression>
        </subreport>

The same can be achieved using Jaspersoft Studio.

enter image description here