I. Overview
1) Problem description
Parameter blank In the drop-down box select all documents, describes how to query all data when parameter blank. In some cases, you want only a few people to have this permission. For example, only administrators can query all data without selecting options, while others must select options before they can query. How should this be implemented?
2) Implementation roadmap
In the post-initialization event of the drop-down box, obtain the current login user, use JS to determine whether it is an administrator, and set whether the drop-down box can be empty according to the judgment result.
Note: Mobile is not supported.
II. Example
1. Data preparation
Create dataset ds1, SQL statement:SELECT * FROM Sales_Volume where 1=1 ${if(len(Region)==0,"","and Region='"+Region+"'")}
2. Report design
1) Design table as shown below:
2) Add region widget and configure data dictionary in parameter panel, as shown below:
3. Setting post-initialization events
1) Add a post-initialization event to the dropdown widget
2) Set the parameter named user and the value of the parameter is $fine_username
3) The JavaScript code is as follows:
if (user == "admin") { this.options.allowBlank = true; } else { this.options.allowBlank = false; }
4. Effect preview
Save the report, click Pagination Preview, the effect is as shown below:
III. Download the template
Click to download the template: