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

TreeView - Drag & Drop

  • Drag-drop.razor
Loading the demo source code...please wait.

Description

Telerik UI for Blazor TreeView displays data in a tree-like structure. One of the main functionalities it gives is drag and drop. It allows you to move a node or multiple nodes between different parents in the same Treeview or between different component instances.

To enable the drag and drop functionality, set the Draggable parameter to true. Then, use the OnDrop event to handle the drag and drop operations and modify the data source as per the application business logic.

The OnDrop event fires when dropping a node into a new location. That allows you to manipulate the data collection based on where the user dropped the element.

You can find the following fields in the OnDrop arguments of type TreeViewDropEventArgs:

  • Item - an object that represents the dragged node. It can get cast to your model class.
  • DestinationItem - an object that represents the node over which the Item is dropped to. It can get cast to your model class.
  • DropPosition - an enum - its members allow you to determine the exact position of the dropped item relative to the position of the DestinationItem:
  • After
  • Below
  • Over
  • DestinationTreeView - the reference of the TreeView in which the node is dropped. That is applicable when you drag and drop nodes between different instances of the component.

Note that - the OnDrop event fires for the TreeView where the item originally was if you drag and drop items from one instance of the TreeView to another.

This TreeView Drag & Drop 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.
Reload