# Drag Grid Rows Into Custom Container

## Environment

<table>
    <tbody>
        <tr>
            <td>Product</td>
            <td>Progress® Kendo UI Grid</td>
        </tr>
    </tbody>
</table>

## Description

How can I drag rows from the Kendo UI for Angular Grid and drop them into a custom container?

## Solution

To drag Grid rows and drop them into a custom container:

1. Create a wrapper container of the Grid and the custom container and apply the built-in [`DragTargetContainer`](https://www.telerik.com/kendo-angular-ui-develop/components/utils/draganddrop/drag-container) and [`DropTargetContainer`](https://www.telerik.com/kendo-angular-ui-develop/components/utils/draganddrop/drop-container) directives.
   ```html
   <div #wrapper
       kendoDragTargetContainer
       kendoDropTargetContainer
       ... >
       <kendo-grid [data]="inStockData">   </kendo-grid>
       <div class="custom-container"></div>
   </div>
   ```

2. To define the drag and drop targets, configure the directives' properties.
   ```html
   <div ...
       dragTargetFilter=".k-master-row"
       dropTargetFilter=".custom-container"
       [dragData]="dragData"
       [hint]="{ hintClass: 'rowHint' }"
       (onDrop)="onDrop($event)"
       dragHandle=".reorder-icon">
   </div>
   ```

3. Use the [`dragData`](https://www.telerik.com/kendo-angular-ui-develop/components/utils/api/dragtargetcontainerdirective#dragdata) callback to fetch the row index.
   ```ts
   public dragData = ({ dragTarget }) => {
       return Number(dragTarget.getAttribute('data-kendo-grid-item-index'));
   };
   ```

4. Use the fetched index to reorder the rows and invoke the `notify()` method of the directives to reflect the changes.
   ```ts
   public onDrop(e: DropTargetEvent): void {
       const fromIndex = e.dragData;
       // update data
       this.dragTargetContainer.notify();
       this.dropTargetContainer.notify();
   }
   ```

The following example demonstrates how to reorder rows from Grid to a custom container.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/row-reordering-container/source.txt)

## Suggested Links

* [Row Reordering](https://www.telerik.com/kendo-angular-ui-develop/components/grid/rows/reordering)
* [Drag and Drop Rows Between Grids](https://www.telerik.com/kendo-angular-ui-develop/components/grid/rows/drag-and-drop)
