Overview
Expected Effect
During parameter linkage, parameters with hierarchical relationships need to be set based on the hierarchical relationships. When your operation does not follow the hierarchical relationships, a pop-up prompt box needs to be displayed.
For example, the following figure shows the effect. During data query, you need to select the values of parameters according to the order: the shipper's region and then the shipper's city. When you select the shipper's city directly, a prompt box is displayed, indicating that the operation is illegal.
Implementation Method
You can add a Before Editing event by JS for the child parameter widget. In this case, if the value of the parent parameter widget of the child parameter widget is empty, a prompt box is displayed, indicating that the operation is illegal.
Example
Data Preparation
Create a dataset ds1 with the SQL statement Select * from Orders where "Shipper's region" ='${shipper_region}' and "Shipper's city"='${shipper_city}', as shown in the following figure.
Create a database query ds2 with the SQL statement Select "Shipper's region" from Orders, as shown in the following figure.
Create a database query ds3 with the SQL statement Select "Shipper's city" from Orders where "Shipper's region"='${shipper_region}', as shown in the following figure.
Table Design
1. Design the table style and drag the corresponding fields into the table, as shown in the following figure.
2. Click Add All to add the shipper_region and shipper_city parameters to the parameter management panel, and select Drop-down Box Widget, respectively, as shown in the following figure.
3. Select the drop-down box widget shipper_region, click , and set Type to Data Query, set Dataset to ds2, set Actual Value and Display Value to Shipper's region, respectively, in the Data Dictionary setting box, as shown in the following figure.
4. Select the drop-down box widget shipper_city, click , and set Type to Data Query, set Dataset to ds3, set Actual Value and Display Value to Shipper's city, respectively, in the Data Dictionary setting box, as shown in the following figure.
Event Adding
Select the drop-down box widget shipper_city, and add a Before Editing event by JS. The JS code is as follows:
var a=_g().getParameterContainer().getWidgetByName('shipper_region').getValue();
if(a.length<=0){
FR.Msg.alert("Prompt","Please select the shipper's region first."+a);
};
Effect Display
PC
Save the report and click Pagination Preview. When you select a shipper's city from the drop-down box shipper_city, the prompt "Please select the shipper's region first." is displayed. When you select a shipper's region before selecting a shipper's city, the data is normally displayed, as shown in the following figure.
Mobile Terminal
The following figure shows the preview effect on the DataAnalyst app and the HTML5 terminal.
Template Download
For details, you can download the template Pop-up Prompt Box for Layer Limit During Parameter Linkage by JS.cpt.