Selected all the check box by default after selecting drop down box

  • Last update:  2021-02-22
  • I. Overview

    1. Expected effect

    In parameter linkage query, you want to select all parameter values in the check box after the drop-down box is selected, as shown in the following figure:

    1.gif


    2. Implementation ideas

    Add after editing events to the drop-down box, use js to call SQL built-in formula, and then change the value to the format required by the check box.


    II. Example

    1. Data preparation

    1) Create a new data query data set DS1, and the SQL statement is: 

    SELECT * FROM MapEN 

    where pid='${A}' and provinces in ('${B}')

    Note: this dataset is used to bind cell data, where pid field is the name of province and province field is the name of city.

    截屏2021-02-22 上午9.49.18.png

    2) Create a new data query data set DS2, and the SQL statement is: 

    select provinces from MapEN

    where pid='${A}'

    Note: this dataset is used to bind the drop-down check box widget data dictionary.

    3.png


    2. Design form

    Drag the corresponding field in DS1 data set into the cell, and the table style is as follows:


    3. Setting widgets

    1) Enter the parameter pane editing interface, add two dataset parameters A and B to the parameter panel, select the drop-down box widget for parameter A, and select the drop-down check box widget for parameter B, as shown in the figure below:


    2) Select the drop-down box widget and bind the widget data dictionary, as shown in the following figure:

    6.png

    3) Select the drop-down check box widget, bind the widget data dictionary, set the widget return value type to string, and the separator is ', ', as shown in the following figure:

    7.png


    4. Adding events

    Select the drop-down box widget to add a after editing event to the widget, as shown in the following figure:

    8.png

    The JavaScript code is as follows:

    var a=this.getValue();//get the value of the drop down box 
    var b=contentPane.parameterEl.getWidgetByName("B");//get the drop down check box widget 
    var c=FR.remoteEvaluate('=sql("FRDemo","SELECT distinct Provinces from MapEN where pid=\''+a+'\'",1)');
    //use JS to evaluate SQL query and get the provinces info
    var e=c.toString().replace(',','\',\'')//convert to string 
    setTimeout( function(){
    b.setValue(e);
    }, 300 ); 


    5. Effect preview

    1) PC terminal

    Save the report and click pagination preview. The effect is as shown in I.1:

    2) Mobile terminal

    Both app and H5 preview are supported, and the effect is shown in the following figure:

    9.gif


    III. Template download

    For completed templates, please refer to:

    %fr_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Parameter\Dd_select_all.cpt

    Click to download the template:

    Dd_select_all.cpt

    IV. Precautions

    After selecting the parameter value from the drop-down box, an error may be reported: this call has security risks. If you need to use it, please modify the script call formula restrictions in security management, as shown in the following figure:

    At this time, just log in to the decision-making platform and close the script call formula restriction under manage > Security > Security.


    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