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

TreeView - Events

CONSOLE Clear log
  • Events.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 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.

This Blazor TreeView Events 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.