mikeb
mikeb

Reputation: 727

Bypassing parameters in ireport 5.6.0

I created a simple report in i-report and i added a parameter on a field salary. Now every time i click on preview i get the parameter pop-up to filter. And if the value if not correct i get a blank page. Now that's exactly what i was trying to do. However i am wondering if there's a way to enter a certain value in the parameter box to display all records. Any idea if this possible and if yes how? Thank you.

WHERE EMPLOYEES."SALARY" = ${P1}

enter image description here

Upvotes: 1

Views: 319

Answers (1)

Petter Friberg
Petter Friberg

Reputation: 21710

You need to change your query (lets imagine that SALARY is numeric, Double). to

WHERE EMPLOYEES."SALARY" = $P{parameter1} OR 0=$P{parameter1}

and define your parameter with a defaultValueExpression and set attribute isForPrompting="false"

<parameter name="parameter1" class="java.lang.Double" isForPrompting="false">
    <defaultValueExpression><![CDATA[new java.lang.Double(0)]]></defaultValueExpression>
</parameter>

You will see no more prompt and display all data, if SALARY is of other class naturally you need to adjust the example accordingly.

Upvotes: 1

Related Questions