New to Telerik UI for Blazor? Download Free 30-day trial

TreeView - Flat Data

  • Flat-data.razor
Loading the demo source code...please wait.

Style in ThemeBuilder

  • Custom SASS variables
  • Atomic customizations
  • Sharing projects
Start Theming

Description

Telerik UI for Blazor TreeView displays data in a tree-like structure. It allows you to navigate through the items and their children. One of the main ways to provide data to TreeView is using flat data.

The component rendering stays the same regardless of the data type. Yet, its configuration will be different when using flat or hierarchical data. The current demo targets data binding to flat data.

The flat data means that the entire collection of Treeview items is available at one level, unlike when using hierarchical data. The parent-child relationships are created through internal data in the model - the ParentId field which points to the Id of the item that will contain the current item. The root level has null for ParentId. One node at least needs a null value so that the TreeView renders anything. The HasChildren field needs the correct value - for items that have children, set it to true so that the expand arrow is getting rendered.

You can also take a look at the Treeview data binding basics.

The demo above demonstrates a Telerik Blazor TreeView component that uses flat data. The parent-child relationship is created through the Parent and Id fields of the TreeItem model.

This TreeView Flat Data example is part of a unique collection of hundreds of Blazor demos, with which you can see all Telerik UI for Blazor components and their features in action. View the source code of the demos from the library or directly adapt, and edit them and their theme appearance in Telerik REPL for Blazor or ThemeBuilder.

Support & Learning Resources

An error has occurred. This application may no longer respond until reloaded.