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:
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.
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.
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:
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:
4. Adding events
Select the drop-down box widget to add a after editing event to the widget, as shown in the following figure:
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:
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:
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.