New to Kendo UI for Angular? Start a free 30-day trial

Data Binding

The TreeView provides core settings for data binding scenarios and enables you to work with various types of data.

Basics

The TreeView exposes the following core data-binding options:

  • nodes (field)—Renders the collection which will be visualized as a top-most level.
  • textField (field)—Determines the node field that will be displayed.
  • hasChildren (function)—Determines if a given node has children.
  • children (function)—Supplies the child node based on the provided parent.
Example
View Source
Change Theme:

Hierarchical Data Binding

To render a hierarchical set of data, implement the children and hasChildren functions.

Example
View Source
Change Theme:

Built-in Directives

The built-in data-binding directives provide specialized implementations of required callbacks and events, simplify data binding, minimize boilerplate code, and support flat or heterogeneous data.

The TreeView supports the following built-in directives:

Types of Data

The TreeView provides options for binding it to:

Local Heterogeneous Data

The following example demonstrates how to use kendoTreeViewHierarchyBinding to bind the TreeView to local data. The childrenField option indicates which field of the parent node contains the children. Setting the textField to an array allows you to have separate field names for each level.

Example
View Source
Change Theme:

Remote Heterogeneous Data

The following example demonstrates how to fetch remote data and bind the TreeView to it. While the function that is assigned to the hasChildren setting signals if the given parent node has child nodes, the children option fetches and supplies the data for the child nodes.

Example
View Source
Change Theme:

Flat Data

The following example demonstrates how to use kendoTreeViewFlatDataBinding to bind the TreeView to flat data. By using the idField and parentIdField to configure the relation between parent and child nodes, you can convert flat data to hierarchal structure.

Example
View Source
Change Theme: