Report’s sections controlled by input control

Requirement: In this blog, I am going to discuss how we can enable/disable the different sections of the jasper report through input control.

Solution overview: In main report I am using two subreports which will be linked to input controls through print when expression. Let us discuss in detail how we can achieve this.

Detailed Solution:

  1. Create main report in jasperstudio. Here I am considering you know how to create report in jasper.
  2. Again create two subreports in main report and linked to already existing reports.
  3. After done with steps 1 & 2,create parameter in main report as “reportsection”:blog-1
  4. In ‘print when expression’ of subreports, type the expression as shown in screenshot below:blog-2 
  5. Similarly, update the ‘print when expression’ of subreport2.
  6. Create input control on server:

    a.Type: Multi select list of values.

    b. Name the input control as “Report Section” and parameter name should be same as in report parameter. Here it is “reportsection”.

      c. In tab “Edit list of Values”, provide the name and value.Value will contain the name of   subreport file name.e.g,

  •       subreport name: sample1.jrxml,
  •       subreport name: sample2.jrxml
  •       Name: “Sample 1”and Value: “sample1”
  •       Name: “Sample 2”and Value: “sample2”
    b3

b5

b5

  1. Link the input control with main report on jasperserver.

  7. On executing report you’ ll be able to show and hide the subreport sections of the report on click of input control. Refer the screenshots below:b7

b8

b9

Hope it helps!!

Thanks,

Nisha Sahu

Leave a Reply