New to Telerik UI for Blazor? Download Free 30-day trial
TreeView - Events
- EXAMPLE
- VIEW SOURCE
- EDIT IN TELERIK REPL
- Change Theme
default
- Events.razor
Description
Telerik UI for Blazor TreeView exposes various events that let you respond to the user actions.
OnExpand
OnItemClick
OnItemDoubleClick
OnItemContextMenu
SelectedItemsChanged
CheckedItemsChanged
ExpandedItemsChanged
The TreeView fires OnExpand
, OnItemClick
, OnItemDoubleClick
, and OnItemContextMenu
events for the corresponding user action – expand/collapse (either with the mouse, or with the keyboard), click/press enter on/taps (for mobile devices), double click, and right-click nodes. You can handle them to update the actual data source.
Additionally, the OnExpand
allows you to implement load on demand if needed
The SelectedItemsChanged
event fires when the selection is enabled and the user clicks on a new item.
The CheckedItemsChanged
event fires every time the user uses a checkbox to select a new item.
The ExpandedItemsChanged
event fires every time the user expands or collapses a TreeView item.
If you set the ShouldRender
field of given event arguments to true, the component will re-render after the event (it will call StateHasChanged()
). That can be useful if you need to change its parameters or state during the event execution and especially if you need to execute async
logic in the event handler.
The current demo showcases handling all TreeView events and logging them in an EventLog
.