Selecting All Values in the Checkbox After Value Selecting in the Drop-down Box

  • Last update:June 08, 2025
  • Overview

    Expected Effect

    During parameter-linked query, after selecting a value in the drop-down box, you want all parameter values to be selected automatically in the drop-down checkbox. The following figure shows the effect.

    Implementation Method

    You can add an After Editing event to the drop-down box, call SQL built-in formulas by JS, and convert the values into the required formats for the checkbox.

    Example

    Data Preparation

    1. Create a database query ds1 with the SQL statement SELECT * FROM MapENwhere pid='${A}' and provinces in ('${B}').

    iconNote:
    The dataset is used for binding cell data. In the SQL statement, the pid field represents the province name, and the provinces field represents the city names.

    2. Create a database query ds2 with the SQL statement select provinces from MapEN. where pid='${A}'.

    iconNote:
    The dataset is used for binding the data dictionary of the drop-down checkbox widget.

    Table Design

    Drag the corresponding fields from dataset ds1 into the cells and design the table style, as shown in the following figure.

    Widget Setting

    1. Enter the editing page of the parameter panel, add the two dataset parameters A and B to the parameter panel, select Drop-down Box Widget for the widget of parameter A, and select Drop-down Checkbox Widget for the widget of parameter B, as shown in the following figure.

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

    3. Select the drop-down checkbox widget, bind the data dictionary of the widget, set Returned Value’s Type to String, and set Separator to ',', as shown in the following figure.

    Event Adding

    Select the drop-down box widget, and add an After Editing event to the widget, as shown in the following figure.

    The JavaScript code is as follows.

    iconNote:

    1. The FR.remoteEvaluate API poses certain security risks. Use the API as needed based on your situation. For details, see Global API - FR.

    2. You need to modify the code to obtain the cell value for the widget linkage in the cell during data entry. 

    var a=this.getValue();//Get the value of the current drop-down box.
    var b=contentPane.parameterEl.getWidgetByName("B");//Get the drop-down checkbox widget.
    var c=FR.remoteEvaluate('=sql("FRDemo","SELECT distinct Provinces from MapEN where pid=\''+a+'\'",1)');
    //Use JS to invoke the SQL function to query and obtain the filtered information of provinces.
    var e=c.toString().replace(',','\',\'')//Convert values into strings in the required formats of the drop-down checkbox.
    setTimeout( function(){
    b.setValue(e);
    }, 300 );//Assign the value to the checkbox with a 300-millisecond delay.

    Effect Display

    1. PC

    Save the report and click Pagination Preview. The following figure shows the effect.

    2. Mobile Terminal

    The report can be previewed on the DataAnalyst app and the H5 terminal. The following figure shows the effect.

    Template Download

    Completed template can be found in %FR_HOME%\webroot\WEB-INF\reportlets\doc\Parameter\Dd_select_all.cpt.

    For details, you can download the template Selecting All Values by Default in the Checkbox After Selecting a Value in the Drop-down Box.cpt.

    Notes

    After you select a parameter value from the drop-down box, an error message “This call poses security risks. If you need to call it, modify Forbid Script to Call Formula in Security Management.” may be displayed, as shown in the following figure.

    In this case, you only need to log in to the decision-making system, choose System Management > Security Management > Security, and disable Forbid Script to Call Formula.

    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