Jump to content
We've recently updated our Privacy Statement, available here ×

Display Multi Select Parameter Choices


L Kark

Recommended Posts

Hello. I have a report which I am designing in TIBCO Jaspersoft Studio and then publishing to the Jasper Server. I have a query based multi select input parameter in this report (parameter type: list). I would like to be able to display the word "All" on the report if the user chooses to 'select all' in the input parameter. Is there a way to determine if the user selected all available options in the multi select parameter? Thank you.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create a new dataset in your report called as parameter count

Use the same sql as the parameter is using, instead of getting any columns, get a count of parameter values

Create a Table element based on the above dataset and write a ternary expression to display the "ALL" or Something else.

Here is a sample jrxml

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.4.2.final using JasperReports Library version 6.4.1  --><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="parameterCount" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="afcffb2c-62fc-41ec-9f38-8f5ffbf1e460">    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>    <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">        <box>            <pen lineWidth="0.5" lineColor="#000000"/>            <topPen lineWidth="0.5" lineColor="#000000"/>            <leftPen lineWidth="0.5" lineColor="#000000"/>            <bottomPen lineWidth="0.5" lineColor="#000000"/>            <rightPen lineWidth="0.5" lineColor="#000000"/>        </box>    </style>    <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">        <box>            <pen lineWidth="0.5" lineColor="#000000"/>            <topPen lineWidth="0.5" lineColor="#000000"/>            <leftPen lineWidth="0.5" lineColor="#000000"/>            <bottomPen lineWidth="0.5" lineColor="#000000"/>            <rightPen lineWidth="0.5" lineColor="#000000"/>        </box>    </style>    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">        <box>            <pen lineWidth="0.5" lineColor="#000000"/>            <topPen lineWidth="0.5" lineColor="#000000"/>            <leftPen lineWidth="0.5" lineColor="#000000"/>            <bottomPen lineWidth="0.5" lineColor="#000000"/>            <rightPen lineWidth="0.5" lineColor="#000000"/>        </box>    </style>    <subDataset name="paramCount" uuid="da6302aa-23ff-4f8c-ba13-809fe1a79241">        <property name="com.jaspersoft.studio.data.sql.tables" value=""/>         <parameter name="arrayListParam" class="java.util.ArrayList">            <defaultValueExpression><![CDATA[Arrays.asList("1", "2", "3")]]></defaultValueExpression>        </parameter>        <queryString language="SQL">            <![CDATA[select count(*) as totalCount from (    select 1 from dual union     select 2 from dual union     select 3 from dual )]]>        </queryString>        <field name="TOTALCOUNT" class="java.math.BigDecimal"/>    </subDataset>    <parameter name="arrayListParam" class="java.util.ArrayList">        <defaultValueExpression><![CDATA[new ArrayList(Arrays.asList("1", "2", "3"))]]></defaultValueExpression>    </parameter>    <queryString>        <![CDATA[select * from dual]]>    </queryString>    <field name="DUMMY" class="java.lang.String"/>    <background>        <band splitType="Stretch"/>    </background>    <title>        <band height="30" splitType="Stretch">            <staticText>                <reportElement x="0" y="0" width="802" height="30" uuid="79b34a17-1afc-4f38-a307-b09ef0af02ca"/>                <text><![CDATA[Parameter All]]></text>            </staticText>        </band>    </title>    <detail>        <band height="30" splitType="Stretch">            <componentElement>                <reportElement x="0" y="0" width="802" height="30" uuid="dbadd6a6-8363-411e-a34f-6736d5c0f7c3">                    <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>                    <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>                    <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>                    <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>                </reportElement>                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">                    <datasetRun subDataset="paramCount" uuid="81c160d1-35bf-4abd-a6e9-a87f7a0338d8">                        <datasetParameter name="arrayListParam">                            <datasetParameterExpression><![CDATA[$P{arrayListParam}]]></datasetParameterExpression>                        </datasetParameter>                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>                    </datasetRun>                    <jr:column width="200" uuid="0651b07b-5ea1-4d1b-990e-ccb134c9b7fb">                        <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>                        <jr:detailCell style="Table_TD" height="30">                            <box>                                <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                                <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                                <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>                            </box>                            <textField>                                <reportElement x="0" y="0" width="200" height="30" uuid="ba8e0370-1610-4fdd-aac8-4bce9911c3b5"/>                                <textElement>                                    <font size="14"/>                                </textElement>                                <textFieldExpression><![CDATA[$F{TOTALCOUNT}.intValue() == $P{arrayListParam}.size() ? "All" : $P{arrayListParam}]]></textFieldExpression>                            </textField>                        </jr:detailCell>                    </jr:column>                </jr:table>            </componentElement>        </band>    </detail></jasperReport>[/code]

 

 

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...