Trees

Creating a tree

A tree is a way to display data. It is formed from entities.

image

  1. Create an entity from three fields (see more details in Creating a table, Creating a view, Creating a projection):

    • field 1 - primary key;
    • field 2 - names of tree elements;
    • field 3 - element’s parent key.
  2. On field 3 set the foreign key from field 1 (see more details in Installing a foreign key).

  3. Fill in the entity data.

  4. Add a menu item for the entity (see more details in Adding a menu item). In the “Style” field, specify the value “treedetailed”.

Creating a tree with classifiers

In the tree with classifiers, in addition to nesting, criteria and classes are created.

Criterion - a sign for evaluating something. The criterion allows you to select classes and classify subjects according to them. The classification criterion “color” can be divided into classes: red, blue, yellow.

  1. Create two entities (see more details in Creating a table, Creating a view, Creating a projection).

    Entity 1:

    • field 1 - primary key;
    • field 2 - names of tree elements;
    • field 3 - key ancestor of the element;
    • field 4 - foreign key of entity 2 (added after creating of entities 2).

    Entity 2:

    • field 5 - primary key;
    • field 6 - names of criteria;
    • field 7 - foreign key of entity 1.
  2. On field 3 set the foreign key from * field 1 * (see more details in Installing a foreign key.

  3. On field 4 set foreign key from field 5 (see more details in Installing a foreign key.

  4. On field 7 set the foreign key from field 1 (see more details in Installing a foreign key.

Setting up the tree

If there are several foreign keys or they are not explicitly specified: specify the parent, left and right keys.

  1. Go to [Selected entity] > button alt [More] > the button alt [Setup…].

  2. In the detailed form, click alt [Edit] to switch to edit mode.

  3. Enter in the field “Additional parameters” :

    {
      "parent_property": "a",
      "left_key_property": "b",
      "right_key_property": "c"
    }
    

    Parameters can be specified selectively.

    Instead of a, b and c, enter:

    • instead of “a” - a field containing the parent keys;
    • instead of “b” - a field containing the left key;
    • instead of “c” - a field containing the right key.

    Learn more about nested sets in Nested set model.

  4. Click the button alt [Save] to save changes or click alt [Cancel] to exit the edit mode without saving.