Purpose


It serves for output and creation of data in a hierarchical form (tree structure). An example of hierarchical data is the structure of a company.



Description

Using the component, in many ways similar to using the ComboBox component. To use the TreeView component, you need to create a separate database table and a foreign key in another database table, which will store the user's selection. To use this component, you must also create an additional field in the database table (Parent ID), the field is required for the formation of records in a hierarchy, it automatically stores the identifier of the parent record.


Let's look at an example where an employee can be assigned a position using the TreeView component.


The database structure of this example:




The form for creating/editing a record, where you can select a position for the employee will look like this:




The TreeView component is configured as follows:


1. Select an external key*, which will save the user's selection, similar to how it is saved in the ComboBox component. You should also select the field of "INTEGER" type, which will automatically save identifier, indicating the parent record. This is the field used by the system to form the hierarchy of records in the database table.

*Instead of a foreign key, you can write the table name, if the creation of a foreign key for this table is not planned in the database structure. I.e. instead of "employees.id_OrgStructure" you can write "OrgStructure"


2. Choose which database table fields we need in the component.
In this example, we need a job position and a comment.

We also give names to the headers for the columns.

In the columns , you can set the formula, to calculate the totals and alignment. More info.


3. You can filter records by conditions. The syntax of the conditions is similar to the syntax of the SQL query language in the WHERE section. It is acceptable to use calculated fields in this field, which must be of the form: {tablename.calculated_field_name}


Here you can download the project with this example.