Successfully!

Error!

Tree Dataset

  • Last update:  2021-01-18
  • I. Overview

    1) Tree datasets are used to construct tree-like hierarchical relationships, such as hierarchical structure of departments and regions. 

    1605000768574020.gif

    2) Each original data needs an original tag field and a parent tag field, and a tree dataset is constructed according to the two fields.

    3) Data sources in the Designer can be divided into two types according to their scope of application: Template dataset  and server dataset. We use template dataset as an example here. The operation method of server datasets is similar to that of template datasets, and will not be discussed here.

    You will learn
    • Steps

      • Create an original dataset

      • Preview original data

      • New tree dataset-method 1

      • New tree dataset-method 2

      • Preview effect

    II. Steps

    1. Create an original dataset.

    1. We use DB query as an example. You can refer to Database Query. We use FRDemo as the data source. SQL statement:

    SELECT * FROM CorporationDepartment

    1605000773221608.png 


    2. Preview original data

    The original data meets the following two conditions:

    • Condition 1: each department has [DepartmentID] and [SuperiorID], with the former being the original tag field which should be filled with the ID of the department, and the latter being the parent tag field which should be filled with the ID of superior department of the department.

    • Condition 2: the departmentID field of the company department follows some rule, that is, only one number represents the first layer department, two numbers represent the second layer department, and so on.

    Note: In actual operation, the departmentID and department_name must correspond, and the departmentID cannot be the same.

    1605000786602016.png 


    3. New tree dataset-method 1

    “Build tree according to the parent tag field of the selected dataset” is applicable to the Condition 1 under 1. Create an original dataset-2. Preview original data.

    1. New tree dataset. Click +at the top of the Template Dataset panel. Select Tree.

    1605063352245613.png 

    2. Enter the tree dataset name and select the DB query ds1 created earlier. Click 1605063732842867.png button on the right and you will see original data.

    1605063361867195.png 

    Note: It is important to emphasize that a unique root node (that is, a node whose upper ID is empty) is required. If the root node is not unique, index will not be built properly when building the tree. Finally, when using the drop-down tree widget in front end, some functional problems may occur. For example, the widget cannot display default values and do not support fuzzy search.

    3. Select Build tree according to the parent tag field of the selected dataset. Select [DepartmentID] in the original tag field. Select [SuperiorID] in the parent tag field.

    1605063367991145.png 


    4. New tree dataset-method 2

    “Build tree according to tag field’s length from selected dataset” is applicable to the Condition 2 under 1. Create an original dataset-2. Preview original data.

    1. New tree dataset. Click + at the top of the Template Dataset panel. Select Tree.

    1605063371411798.png 

    Enter the tree dataset name and select the DB query ds1 created earlier. Click 1605063732842867.png button on the right and you will see original data.

    1605063374158923.png 

    Select Build tree according to tag field’s length from selected dataset. Select [DepartmentID] in the original tag field.

    1605063377330374.png 

    Note: FineReport automatically recognizes the rules in the departmentID field.


    5. Preview effect

    1. ClickPreviewat the bottom right and you can preview effects.

    1605063382725016.png 

    2. As shown in the figure below, 3 fields were automatically generated in the data table, namely: FR_GEN_0 (first layer), FR_GEN_1 (second layer) and FR_GEN_2 (third layer).

    1605063388268976.png 

    Take the data framed in red as an example:

    Headquarter (DepartmentID: 1) is on the first layer, Financial department (DepartmentID: 13) is on the second layer, and Accountant (DepartmentID: 132) is on the third layer.

     

    Typical application: Build a drop-down treeDrop down tree

     


    Attachment List


    Theme: Lauren待翻译
    • Helpful
    • Not helpful
    • Only read

    Doc Feedback