Overview
Version
| Report Server Version | Functional Change |
|---|---|
| 11.0 | / |
Application Scenario
During a data query, different data is often displayed based on different parameter values. However, in this case, you want to jump to different templates based on different parameter values, as shown in the following figure.

Implementation Method
You can prepare three templates, namely, sub-template one, sub-template two, and a parameter template, to realize the effect.
1. You can prepare sub-template one and sub-template two, and save the two templates to the corresponding paths, respectively.
2. You can create a template, and set two drop-down box widgets and one query button on the parameter panel.
You can set data dictionaries for the two drop-down box widgets, respectively. Specifically, in Data Dictionary, you can set Actual Value and Display Value to ORDERID from the ORDERS_OLD table for one drop-down box, and set Actual Value and Display Value to the two sub-templates after setting Type to Custom for the other drop-down box.
You can set a Click event for the query button to jump to the selected report and pass the order ID to the report.
Example
Sub-template Preparation
1. Sub-template one: %FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\Advanced\Father1.cpt.
You can also download the template Father1.cpt and save it to the corresponding path.
2. Sub-template two: %FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\Advanced\Son.cpt.
You can also download the template Son.cpt and save it to the corresponding path.
Parameter Template Design
1. Choose File > New General Report on the menu bar, as shown in the following figure.

2. Click the edit icon on the parameter panel to enter the editing page of the parameter panel. Drag two label widgets, two drop-down box widgets, and one query button into the parameter panel, as shown in the following figure.

3. Select label0 on the right, click Attribute, and set Widget Value to the string Order ID:. Similarly, set Widget Value of label1 to View Table:.
The following figure shows the effect.

4. Select comBox0 on the right, click Attribute, and set Widget Name to orderID. Similarly, set Widget Name of comBox1 to cptName.
The following figure shows the effect.

5. Select orderID on the right, click Attribute, click
next to Data Dictionary. To set Data Dictionary, set Type to Database Table, set Database to FRDemo, set Database Table to ORDERS_old, and set Actual Value and Display Value to ORDERID, respectively, as shown in the following figure.

6. Select cptName on the right, click Attribute, click the xxx icon next to Data Dictionary. To set Data Dictionary, set Type to Custom and set Actual Value to the report paths. Set Display Value of Father1.cpt to Orders and Display Value of Son.cpt to Order Details, as shown in the following figure.

7. Select formSubmit0 on the right, click Event, click +, and set a Click event for the query button, as shown in the following figure.

The JS code is as follows:
var orderID = this.options.form.getWidgetByName("orderID").getValue();
var cptName = this.options.form.getWidgetByName("cptName").getValue();
window.location = "${servletURL}?viewlet=" + cptName + "&ID="+ orderID;
Note:If the name of the sub-report contains Chinese characters, the third line of the code requires the use of the encodeURI() function for encoding. The following shows the code.
window.location = "${servletURL}?viewlet=" + encodeURI(cptName) + "&ID=" + orderID;
Note:If the sub-report is a data entry report, you need to add &op=write behind cptName in the third line of the code. The following shows the code.
window.location = "${servletURL}?viewlet=" + cptName + "&op=write" + "&ID=" + orderID;
Note:If you want to open the report in a new window, you need to modify the third line of the code as follows.
window.open("${servletURL}?viewlet=" + cptName + "&ID=" + orderID,"_blank")
Effect Display
PC
Save the report and click Pagination Preview. The effect is the same as that shown in section "Application Scenario."
Mobile Terminal
The effect cannot be previewed on mobile terminals.
Template Download
For details, you can download the template Viewing Different Reports Based on the Parameter Values.cpt.