JasperReports Server parameter dependency

1.5k views Asked by At

I have a report which has two input-parameter. Both have a dropbox where i can select values. Let's say ParameterA and ParameterB. Is it possible to make ParameterB dependent from ParameterA?

for example: If i choose in ParameterA the carbrand 'Honda' in ParameterB i should only see all car models by Honda - like Accord, Civic and so on.

Is there such a possibility in iReport/JasperReports Server?

1

There are 1 answers

0
Sharad On

Yes JasperReport server provide this functionality which is called cascading input controls.

With cascading parameters, the list of values for one parameter depends on the value chosen in preceding parameter.

Order is important for cascading parameters because the dataset query for a parameter later in the list includes references to parameters earlier in the list.

For example suppose we have two input controls and names are Shipcountry and Shipcity, In this condition if we select Shipcountry then next input control Shipcity should show only those cities which belongs to that selected Shipping country.

In JasperSerever create a new input control with resource id p_shipcountry and you do not have to use the data source for this input control, just use the bellow query:-

         SELECT DISTINCT shipcountry FROM orders ORDER BY shipcountry;

Create second input control with resource p_shipcity , which will be cascading input control, but you have to use the data source for this input control and use the bellow query:-

          SELECT DISTINCT shipcity FROM orders
          WHERE shipcountry= $P{p_shipcountry} ORDER BY shipcity;

For more detail you can see this post :-

Cascading Input Controls