New to Telerik UI for Blazor? Download Free 30-day trial
TreeView - Selection
- EXAMPLE
- VIEW SOURCE
- EDIT IN TELERIK REPL
- Change Theme
default
Selection Mode
MultipleSelected Items:
- Selection.razor
Description
Telerik UI for Blazor TreeView allows you to select one or more nodes and exposes an option to configure the selection mode. The selection mode of the TreeView controls how many nodes the user will be able to select. To specify the desired selection mode, use the SelectionMode parameter. It takes a member of the TreeViewSelectionMode enum. The available options are:
None- disable the node selection. This is the default setting.SingleSelection ModeMultipleSelection Mode
If the Single Selection Mode is enabled, the user will be able to select only one node. That option is useful if you want to restrict the user selection to a single value and the desired output of the Blazor TreeView is just one object instance.
The Multiple Selection Mode allows the user to select multiple random nodes. In this case, you can use the SelectedItems parameter of the Blazor component to get or set the selected nodes collection. It accepts an IEnumerable of object and supports two-way binding.
To extract details for the selection from SelectedItems, you need to cast the collection to the correct model type. That is required because you can bind the Treeview to different model types at each level.
The current demo showcases the different Blazor TreeView selection modes.