Skip to main content

Self-Referenced Dataset

  • 2 minutes to read

A data-aware TreeList control is able to connect to any VCL dataset, however only self-referenced datasets are suitable for ExpressQuantumTreeList. In other cases, the TreeList control will not be able to build a tree.

A self-referenced dataset is a dataset that has at least two fields: the Key field and the Parent field.

KeyField values uniquely identify records. The ParentField property designates the dataset field whose values define the record position within a tree structure. The values of the ParentField specify the KeyField value of a record (node in the tree structure), owning the current record (node).

If a record has a ParentField value without a corresponding key field value within the dataset, the record is displayed at the root of the tree structure. Records with the same ParentField value are displayed as child records (nodes) of the record (node), whose KeyField value matches the appropriate ParentField value.

The Key and Parent fields have to be of the same type. Here is an example of a self-referenced dataset and the data-aware TreeList bound to this dataset:

Parent

Key

Name

-1

1

Corporate Headquarters

1

2

Sales and Marketing

2

3

Field Office: Canada

2

4

Field Office: East Coast

2

5

Field Office: East Coast

5

6

Field Office: Singapore

5

7

Field Office: Japan

2

8

Marketing

2

9

Finance

1

10

Engineering