# Drag and Drop

The TreeList component allows you to move its data items in the data tree by Drag and Drop the TreeList rows.

## Getting Started

To enable drag and drop for TreeList rows:

1. Import `TreeListDraggableRow` and `moveTreeItem` from the TreeList package.

   ```tsx
   import { TreeList, TreeListDraggableRow, moveTreeItem, TreeListRowDragEvent } from '@progress/kendo-react-treelist';
   ```

2. Set the [`row`](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistprops#row) prop to `TreeListDraggableRow` — this replaces the default row component with one that supports drag handles.

   ```tsx
   <TreeList row={TreeListDraggableRow} ... />
   ```

3. Handle the [`onRowDrop`](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistprops#onrowdrop) event and use the [`moveTreeItem`](https://www.telerik.com/kendo-react-ui/components/treelist/api/movetreeitem) utility to reposition the dragged item in the data tree.

   ```tsx
   const onRowDrop = (event: TreeListRowDragEvent) => {
       setData(moveTreeItem(data, event.dragged, event.draggedOver, subItemsField));
   };
   ```

The following example demonstrates how to use the Drag and Drop feature to reorder rows within the TreeList hierarchy.

[Demo Source](https://demos.telerik.com/kendo-react-ui/treelist/dragdrop/func/source.txt)

## Suggested Links

* [API Reference of the TreeList](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistprops)
* [API Index of the TreeList](https://www.telerik.com/kendo-react-ui/components/treelist/api)
