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.
- Create main report in jasperstudio. Here I am considering you know how to create report in jasper.
- Again create two subreports in main report and linked to already existing reports.
- After done with steps 1 & 2,create parameter in main report as “reportsection”:
- In ‘print when expression’ of subreports, type the expression as shown in screenshot below:
- Similarly, update the ‘print when expression’ of subreport2.
- 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”
- Link the input control with main report on jasperserver.
Hope it helps!!