Jump to content
We've recently updated our Privacy Statement, available here ×
  • iReports domain report make filters ignored if empty


    yananderson
    • Features: Domains, Filters, Parameters Version: v5.2 Product: iReport Designer

    I struggled to find a solution for this and after combining solutions for similar problems I eventually found this solution.  Hope this helps someone.

    The Problem

    If you have filters running against your report and you dont want the user to be forced to select something for that filter the query returns no records.  I want to be able to make a filter ignored if empty.

    [toc]

    The Solution

    proceed each filter in your domain query string with an additional filter to run the following logic:

    filter  in result set OR <IF filter = empty>1<ELSE>0</IF> in (1)

    Working example

    Parameters:

    <parameter name="OrganisationName" class="java.util.Collection">
        <property name="inputControl" value="true"/>
        <defaultValueExpression>
            <![CDATA[java.util.Arrays.asList(new java.lang.String(""))]]>
        </defaultValueExpression>
    </parameter>
    
    <parameter name="OrganisationName1" class="java.lang.Integer">
        <property name="inputControl" value="true"/>
        <defaultValueExpression>
            <![CDATA[new Boolean($P{OrganisationName}.isEmpty())?1:0]]>
        </defaultValueExpression>
    </parameter>
    

    Domain Query String:

    <![CDATA[
        <query>
            <queryFields>
                <queryField id="dbo_vInteractions.interaction"/>
                <queryField id="dbo_vInteractions.interactionId"/>
                <queryField id="dbo_vInteractions.Person.PersonName"/>
                <queryField id="dbo_vInteractions.Organisation.OrganisationName"/>
                <queryField id="dbo_vInteractions.Location.CountryDescription1"/>
            </queryFields>
            <queryFilterString>
                ((dbo_vInteractions.Organisation.OrganisationName in OrganisationName)
                 or OrganisationName1 in (1))
            </queryFilterString>
        </query>
    ]]>
    

    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...