Example for Automatic Creation of Drop-down Tree Widgets

  • Last update:  2023-10-20
  • Overview

    Version

    Report Server Version

    Functional Change

    11.0

    /

    11.0.6

    • Parent nodes of root nodes in tree datasets of the data dictionary can be not empty.

    • If the drop-down tree creation fails, a prompt pops up, indicating the cause of failure. For details, see section "Implementation Method."

    Preview

    The effect is shown in the following figure.

     1.png

    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.

     2.png

    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."

     3.png

    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.

     4.png

    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.

     5.png

    Changing a Dataset into a Tree Dataset

    1. Create a tree dataset named Tree1.

     6.png

    2. Create a tree through the dataset ds1.

     7.png

    Adding a Drop-down Tree Widget

    Add a dropdown tree widget on the parameter panel.

     8.png

    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.

     9.png

    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.

    11.jpg

    Attachment List


    Theme: Parameter
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy