New to KendoReact? Start a free 30-day trial
Reordering of Rows
You can implement row reordering in the KendoReact Data Grid by using the KendoReact Drag&Drop
, built-in browser APIs or third-party libraries.
KendoReact Drag&Drop
Implementing row reordering requires the following steps:
- Wrap the Grid with the
KendoReact Drag&Drop
component. - Create a
ReorderContext
using React createContext to share thereorder
anddragStart
functions. - Create a
DraggableRow
and pass it to therowRender
prop. Handle theonPress
,onDragStart
,onDrag
,onDragEnd
andonRelease
events to manage the dragging state and movement of rows. - Create a
DragHandleCell
with a visual indicator and pass it to thecell
prop of theGridColumn
to indicate where users can initiate a drag action. - Implement a
reorder
function that will calculate the new position for the dragged item and update the data in the KendoReact Data Griddata
. - Pass the
dragStart
andreorder
function to theReorderContext
.
The following example demonstrates this approach in action:
Change Theme
Theme
Loading ...
Multi-select reordering
The KendoReact Drag&Drop functionality enables advanced scenarios of the drag-and-drop behavior. One of the scenarios is reordering all selected rows.
The following example demonstrates how the drag-and-drop functionality can be combined with multi-row selection.
Change Theme
Theme
Loading ...
Detail row reordering
The following example demonstrates how to combine the drag-and-drop functionality with detail rows.
Change Theme
Theme
Loading ...
Built-in Browser APIs
The following example demonstrates one of the possible approaches which utilizes the HTML Drag and Drop API.
Change Theme
Theme
Loading ...