TREELAYER Function

  • Last update:April 14, 2025
  • Overview

    Syntax: treelayer(TreeObject, Int, Boolean, String).

    Definition: to return the value at the No.n level of a tree object (usually a tree dataset, a drop-down tree, or a view tree). You can set the type of the returned value and the separator.


    Explanation

    Object   ValueDefinition 
    TreeObjectTree object For example: $tree 
    IntValue of the aimed level 1 for the top level, 2 for the second level, with each subsequent layer following this numerical sequence. With a null value, the function returns the value at the bottom level.
    Boolean Type of the returned value 

    false: to return an array (the default value)

    true: to return a string

    String  Separator of the returned string Value in double quotes (the comma by default): ","

    Example

    This example explains the role of the TREELAYER function by displaying the department hierarchy in the FRDemo database with a drop-down tree widget.

    Dataset Creation

    Database Query Creation

    Create a general report, and enter the SQL statement SELECT * FROM department to create a dataset ds1, as shown in the following figure.

     021.png

    Tree Dataset Creation

    Create a tree dataset named Tree1, select the dataset ds1, set Original Tag Field to did, and set Parent Tag Field to fid, as shown in the following figure.

     022.png

    Dataset Preview

    Preview the effect of the tree dataset, as shown in the following figure.

     023.png

    Widget Adding

    Add two widgets on the parameter bar: a drop-down tree widget and a text widget, as shown in the following figure.

     024.png

    Drop-down Tree Widget

    Modify the name of the drop-down tree widget to tree. Select Multiselect and Return Full Hierarchical Path.

    Select Automatic Creation as the value of Data Dictionary, select Tree1 as the value of Tree Dataset to Build, and select department as Actual Value and Display Value, as shown in the following figure.

     025.png

    Text Widget

    Select Formula and enter the formula treelayer($tree, true, "\',\'") for Widget Value, as shown in the following figure.

     026.png

    Effect Display

    Save the template, click Pagination Preview, choose Headquarter > Human resources department > Human resources clerk, and choose Marketing department > Clerk, as shown in the following figure.

     027.png

    According to the formula field in the text widget, the returned value and the separator in preview differ, as shown in the following table.

    Formula Returned Value  Separator Illustration
    treelayer($tree, true, "\',\'") 

    Human resources clerk

    Clerk

    ','028.png
    treelayer($tree, 2) 

    Human resources department

    Marketing department

      ,029.png
    treelayer($tree, 2, true, "\',\'") 

    Human resources department

    Marketing department

    ',' 030.png

    Template Download

    For details, you can download the template TREELAYER Function.cpt

    Attachment List


    Theme: Report Features
    • 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