View different reports based on parameters

  • Last update:  2021-10-12
  • 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
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy