Search code examples
jasper-reportsjasperserver

How to change the report's default drop-down value?


I have used JasperReports Server 5.5 as the reporting module which runs on tomcat. When I add input controls, drop-downs are shown as below.

enter image description here

default value is --- in the drop-downs.

How to change the report's default drop down value(---) to All?


Solution

  • In the case of multiselect parameter of Collection type (java.util.Collection) you do not need to give "All" to select all the values in iReport as default value for that parameter by default it means all the values are selected. But if the parameter is single select of String type then the query for input control in JasperReport Server will be: -

     SELECT *
     FROM (SELECT 'All Country' SHIPCOUNTRY FROM orders
    
     UNION
    
     SELECT DISTINCT SHIPCOUNTRY FROM orders) b
     ORDER BY SHIPCOUNTRY
    

    iReport query for report where you will use parameter in where clause will be : -

    SELECT SHIPCOUNTRY,SHIPCITY
    FROM orders
    WHERE ($P{p_shipcountry}='All' OR SHIPCOUNTRY=$P{p_shipcountry})
    

    Where p_shipcountry is a parameter in iReport and it is single select of String (java.lang.String) type parameter and make the input control mandatory.

    For more detail you can refer my blog.