[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Collapse]Tree List
   [Expand]Product Information
    [Expand]Binding to Data
    [Collapse]Data Representation Basics
      Tree Generation Algorithm in the ASPxTreeList
    [Expand]Data Editing
    [Expand]Data Shaping and Manipulation
     Drag and Drop
    [Expand]Focus and Navigation
     Appearance Customization
     Save and Restore Client Layout
   [Expand]Visual Elements
   [Expand]Member Tables
  [Expand]Card View
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Tree Generation Algorithm in the ASPxTreeList

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.

To build a tree, a tree list's data source should contain two additional fields.

  • Key Field

    This field must contain unique values. This field must be assigned to the ASPxTreeList.KeyFieldName property.

  • Parent Field

    This field must contain values that indicate parent nodes, and the key values for the current node. It should be assigned to the ASPxTreeList.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 KeyField and ParentField fields must be the same.


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


Expanded Concepts

Expanded Task-Based Help

Is this topic helpful?​​​​​​​