I. Overview
1) Requirement description
In a real project, you may need to control the display of the template in full or in part. In the following figure, if Yes is selected, the query result contains information about both the department ID and the upper-level department ID.
2) Implementation roadmap
Radio button group widgets and data set parameters to achieve.
II. Steps
1. Preparing data
Create a general report, create a dataset ds1, SQL statement:
SELECT * FROM CorporationDepartment where 1=1 ${if (flag == 0,"and DepartmentID = '" + id + "'","and (DepartmentID = '" + id + "' or SuperiorID='" + id + "')")}
2. Table design
Design the table as shown below and drag the fields into the corresponding cells:
3. Adding parameter widgets
Edit the parameters panel, click Add All above the widget Settings on the right to generate the parameterswidget. Click the id parameter box, select the Drop-down box widget; Click the flag parameter box and select the radio button group widget.
4. Setting the data dictionary of the parameter widget
1) Setting the data dictionary for the drop-down box widget
Select the widget id from the drop-down list box, set the data dictionary to the Database Table, and select the CorporationDepartment table of the built-in database FRDemoEN. The actual and displayed values are both DepartmentID.
2) Setting the data dictionary for the radio button group widget
Select the radio button group widget named flag, set the data dictionary to Custom, and add two records: the actual value 1 and 0 correspond to the displayed value yes and no respectively.
5. Effect preview
1) PC
Save the template and click page preview, the effect is as shown below:
2) Mobile
The end effect of App and HTML5 is as follows:
III. Download the template
For the completed template, see:
%FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc\Parameter\Radio_button_groups_widget_whether_the_implementation_displays_all.cpt
Click to download the template:
Radio_button_groups_widget_whether_the_implementation_displays_all.cpt