Successfully!

Error!

You are viewing 10.0 help doc. More details are displayed in the latest help doc

View different reports based on parameters

I. Overview

1. Expected effect 

When querying data, different data is generally displayed according to different parameter values, but you may want to jump to different templates according to different parameter values. How to achieve this? As shown below:


2. Implementation ideas

Use 3 templates to achieve: parameter template, sub-template 1, sub-template 2.

Create a separate template for the parameter interface, use the drop-down box widget to select the report to be viewed, click the query to trigger the click event, jump to the corresponding report, and pass the remaining parameters to the report.

JS realizes the refresh of the current page:

window .location = url; 


II. Example 

1.Template design

1) Sub-template preparation 

  • Sub-template 1: %FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\Advanced\Father1.cpt

        Or click to download the template and save it to the corresponding path: Father1.cpt

  • Sub-template 2: %FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\Advanced\Son.cpt

        Or click to download the template and save it to the corresponding path:Son.cpt

2) Parameter template design

To create a new general report, click Template>Template Parameters , and define the two parameters as orderID and cptName respectively .

  • Set the widget type of orderID to the drop-down box, its value selects the ORDERS table in the database table, the actual value and the displayed value both select the ORDERID, as shown in the following figure:  

  • Set the widget type of cptName to the drop-down box, select custom for its value, list the name of the report that needs to be viewed, and the actual value is the corresponding report path, as shown in the following figure:  

  • Query Button event settings, add a click event to the Query Button, as shown in the figure below:

The specific JS 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: The encodeURI() transcoding function needs to be used when the subreport name contains Chinese. The code format is as follows:

window .location = "${servletURL}?viewlet=" + encodeURI (cptName) + "&ID=" + encodeURI (orderID);       

or:

window .location = encodeURI ( "${servletURL}?viewlet=" + cptName + "&ID=" + orderID);       

Note: If the subreport is a filling report, you need to add "&op=write" after cptName.

If you want to open in a new window, change to this code:

window .open( "${servletURL}?viewlet=" + encodeURI (cptName) + "&ID=" + encodeURI (orderID), "_blank" )     


2. Effect preview

1) PC terminal

Save the template and click on the Pagination Preview , as shown in the figure below:

Note: The mobile terminal is not currently supported.


III. Template download

The template has been completed, please refer to: %FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\Parameter\View_different_reports_based_on_parameters.cpt

Click to download the template: View_different_reports_based_on_parameters.cpt

Attachment List


Theme: Parameter
Already the First
Already the Last
  • Helpful
  • Not helpful
  • Only read

Doc Feedback