Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement organizational Tree report in Tree dataset in FineReport

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

It is believed that many inexperienced people do not know what to do about how to implement the organizational tree report in the tree dataset in FineReport. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

In the organization tree report, the id and the parent id implement the organization tree report. If there are many levels, it will be cumbersome to set the filter condition and shape for each cell. Therefore, FineReport provides a special data set-tree data set, which can be recursive automatically with simple settings. It is convenient to implement the organization tree report as follows:

Figure 1

Figure 2

Build a tree

New report, add dataset

Create a workbook, add a dataset ds1 to fetch the original data, and the SQL statement is SELECT * FROM company department.

Define a tree dataset

1) build a tree based on parent fields

Use case: the original table structure conforms to the ID and parentID structure. We can use the parent ID field to generate a tree and add a tree dataset, as shown below:

2) build the tree according to the data length

Use case: all the ID in the original table structure are in one column, and there is no parent ID field, but the ID is regular, the length of each group is the same, and the first N bits of the child are the parent number, add the tree dataset, as shown below:

Preview data

If you preview the tree dataset, you can see that the recursive tree data has been automatically generated. FR_GEN_0 is the highest level, descending in turn, as follows:

Vertical organization tree editing

Drag the corresponding data column into the cell as shown below, and set the left parent of the A2 cell to the left parent of the A1 Magi A3 cell to A2:

Conditional attribute

With the preview data above, we can see that starting from the second-tier FR_GEN_1, there will be blank data. This is because the data stored in the database has the department name and department ID of the department at the next level, and the department level of the department above is one level lower. For example, the first behavior headquarters of the above data, although there are sub-departments under the headquarters, the department name and department ID of the headquarters department should be stored in the database. If the corresponding level of the headquarters is level 1, then there is only FR_GEN_0 layer in the corresponding data record row, and the following two layers, FR_GEN_1 and FR_GEN_2, will have no data and appear blank.

In the process of making a template, there will be blank data from the second level. You need to hide the blank data. Select A2 and A3 cells, add conditional attributes, and hide the row when the data is empty, as shown below:

If the hierarchical structure of the organizational structure is uncertain, that is, some levels have sub-layers and some levels do not have sub-layers, the implementation of the organizational tree report, please see the non-standard organizational tree report.

Other settin

Since the automatically generated field is encoded, you can use a data dictionary to change it to the corresponding department name, as shown in the following figure:

Save and Preview

Save the template and click the paging preview, as shown in figure 1.

Horizontal organization tree editing

Drag the corresponding data column into the cell as shown in the following figure, and set the expansion direction of B1 and C1 cells to horizontal in the right cell property sheet-extended properties.

And set the left parent of the B1 cell to B1, and the left parent of the C1 cell to B1:

Conditional attribute

With the preview data above, we can see that starting from the second-tier FR_GEN_1, there will be blank data. This is because the data stored in the database has the department name and department ID of the department at the next level, and the department level of the department at the upper level will be one level lower. For example, the first part of the above data is listed as the headquarters. Although there are sub-departments under the headquarters, the department name and department ID of the headquarters department should be stored in the database. If the corresponding level of the headquarters is level 1, then there is only FR_GEN_0 layer in the corresponding data record column, and the following two layers, FR_GEN_1 and FR_GEN_2, will have no data and appear blank.

In the process of making a template, there will be blank data from the second level. You need to hide the blank data. Select cells B1 and C1, add conditional attributes, and hide the column when the data is empty, as shown below:

If the hierarchical structure of the organizational structure is uncertain, that is, when some levels have sub-layers and some levels do not have sub-layers, how to implement the organizational tree report, please see the irregular organizational tree report.

Other settin

Since the automatically generated field is encoded, you can use a data dictionary to change it to the corresponding department name, as shown in the following figure:

Save and Preview

Save the template and click the paging preview, as shown in figure 2.

After reading the above, have you mastered how to organize tree reports from tree datasets in FineReport? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report