Skip to main content

Tree Generation Algorithm in the ASPxTreeList

  • 2 minutes to read

The ASPxTreeList is designed to answer the needs of all ASP.NET developers who face the challenge of rendering hierarchical data structures.

The nodes in a tree represent data source records. The Root node is a parent node for all nodes displayed within the ASPxTreeList. This is a special node which isn’t displayed within the ASPxTreeList. The collection of its child nodes can be accessed via the ASPxTreeList.Nodes property. Nodes contained within this collection are displayed as root nodes within the ASPxTreeList.

The data source you bind to the ASPxTreeList control should contain the following fields:

Key Field
A field that specifies a unique key value for each node. Assign the name of this field to the KeyFieldName property.
Parent Field

A field that specifies the key value of the parent node for each node. Assign the name of this field to the ParentFieldName property.

By default, if this value doesn’t point to any other node, the node is added to the ASPxTreeList.Nodes collection, as you see with the first node displayed in the image below. Otherwise, the node is added to its parent’s TreeListNode.ChildNodes collection.

However, if you specify the ASPxTreeList.RootValue property’s value, only those nodes whose parent field value matches the ASPxTreeList.RootValue are added to the collection of root nodes. If the node’s parent field value doesn’t match the ASPxTreeList.RootValue and doesn’t point to any other node, this node isn’t displayed within the ASPxTreeList.

Important

The data types of the Key and Parent fields must be the same.

The image below illustrates an example of an appropriate data source:

cdTreeGeneration

Concepts

Task-Based Help