Hide Group when Subreports within group return no values

0

Hi,

I have a group that contains 3 separate sub reports - each with a vastly different query. This is basically a detailed listing of information - if specific conditions apply. When there is no information to display, I still get a blank page in my report.

How can I remove the group when all 3 subreports are empty?

Code below:

<group name="Group2">
        <groupExpression><![CDATA[$F{PROJECTID}]]></groupExpression>
        <groupHeader>
            <band height="132">
                <subreport>
                    <reportElement positionType="Float" x="-20" y="0" width="476" height="44" isRemoveLineWhenBlank="true" uuid="f23d4dd8-78da-4966-b78b-15dea93bcc17"/>
                    <subreportParameter name="p_prj">
                        <subreportParameterExpression><![CDATA[$F{PROJECTKEY}]]></subreportParameterExpression>
                    </subreportParameter>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    <subreportExpression><![CDATA["repo:r&i.jrxml"]]></subreportExpression>
                </subreport>
                <subreport>
                    <reportElement positionType="Float" x="-20" y="88" width="476" height="44" isRemoveLineWhenBlank="true" uuid="71e03d07-b3dc-4091-ba76-4f33fa5ee396"/>
                    <subreportParameter name="p_prj">
                        <subreportParameterExpression><![CDATA[$F{PROJECTKEY}]]></subreportParameterExpression>
                    </subreportParameter>
                    <connectionExpression><![CDATA[java.sql.DriverManager.getConnection("jdbc:sqlserver://#####;databaseName=####","####","####")]]></connectionExpression>
                    <subreportExpression><![CDATA["repo:Defects.jrxml"]]></subreportExpression>
                </subreport>
                <subreport>
                    <reportElement positionType="Float" x="-20" y="44" width="476" height="44" isRemoveLineWhenBlank="true" uuid="95eccdc4-efae-418d-a581-471d5ab54f30"/>
                    <subreportParameter name="p_prj">
                        <subreportParameterExpression><![CDATA[$F{PROJECTKEY}]]></subreportParameterExpression>
                    </subreportParameter>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    <subreportExpression><![CDATA["repo:Issues.jrxml"]]></subreportExpression>
                </subreport>
            </band>
        </groupHeader>
    </group>

Thank you,

Chris

camnott's picture
86
Joined: Mar 10 2017 - 6:24am
Last seen: 1 year 21 hours ago

1 Answer:

0

I've had to add a subquery to my main report query for each subreport/list/table/chart. Basically, the subquery returns true/false for whether there would be records to be shown in my subreport. Just use the resulting field value in the Print when Expression.

kevin.weinhold's picture
Joined: Mar 15 2018 - 10:57am
Last seen: 1 year 3 months ago
Feedback
randomness