Overview
Version
Report Server Version | Functional Change |
11.0 | / |
11.0.6 |
|
Preview
The effect is shown in the following figure.
Implementation Method
Directly change datasets into tree datasets and directly select tree datasets in the drop-down tree to automatically create layers. Tree datasets must have a clear parent-child relationship.
You need to note the following aspects during the tree dataset creation:
1. The tree dataset creation fails if there are loops in data. A prompt pops up: "tree ComboBoxEditor0 tree widget creation failed. A loop is formed between the data whose original tag field is 111 and 127."
2. The tree dataset creation fails if the parent departments of root departments are empty. You can create tree datasets with empty parent departments in FineReport 11.0.6 and later versions.
Example
Defining a Dataset
1. Prepare a table that can be used to create tree datasets.
Table analysis:
The first row indicates that the headquarter tag is 1, with an empty parent tag. That is, headquarter is a root department with no parent department. Usually, if a department have no parent department, the parent department tag is empty.
The second row indicates that the original tag of Human Resources Department is 11, with its parent department tagged as 1. You can query its parent department based on this tag.
You can know all department and position information in the dataset. According to Parent ID, you can locate Department ID, search for the corresponding department name, and create the parent department.
Notes:
You must find tags in Department ID corresponding to the tags in Parent ID (except empty ones). All values of Parent ID in the above figure have corresponding values in Department ID.
In FineReport versions before 11.0.6, the parent departments of root departments must be empty and cannot be 0 or null.
2. Create a template dataset.
This document takes the built-in company department table in the database FRDemo as an example.
Create a general report and add a dataset named ds1. The SQL statement is select * from Company department.
Changing a Dataset into a Tree Dataset
1. Create a tree dataset named Tree1.
2. Create a tree through the dataset ds1.
Adding a Drop-down Tree Widget
Add a dropdown tree widget on the parameter panel.
Defining a Drop-down Tree
Select the drop-down tree, choose Attribute > Advanced > the XXX icon in Data Dictionary, set Creation Method to Automatic Creation, select the tree dataset Tree1, and set Actual Value to Department ID and Display Value to Department Name.
Demonstration
On PC
Save the template and click Pagination Preview. The effect is shown in section "Preview."
On Mobile Terminals
The effects on the DataAnalyst app and HTML5 are shown in the following figure.