New to Telerik UI for Blazor? Download Free 30-day trial
TreeView - Template
- EDIT IN TELERIK REPL
- Change Theme
Telerik UI for Blazor TreeView displays data in a tree-like structure. It allows you to navigate through the items and their children. These items (nodes) are customizable by defining templates individually.
The component rendering stays the same regardless of the data type. Yet, its configuration will be different when using hierarchical or flat data. The current demo shows the TreeView template using hierarchical data binding. The hierarchical data means that the collection of child items is provided in a field of its parent's model, unlike when using flat data. That is the
Items field by default. If a given node has items, an expand icon will be visible.
ItemTemplate tag under the
TreeViewBinding tag defines the template. It receives the model the item is bound to as its
context. You can use it to render the desired content. The component can have different templates for the different levels in each
Defining a template allows you to render arbitrary content according to the specific application's data and logic. You can use different Blazor components in it and thus provide rich content instead of plain text. Another benefit is the possibility to add DOM event handlers like click, double click, and mouseover if you need to respond to them.