Skip to content

Table - Row Drag

Configure row drag functionality through drag-config, supporting drag sorting, drag handles, drag event listening, and more.

Drag to Reorder Rows

Set row: true in drag-config to enable row drag sorting. Press and hold the row with the mouse to drag.

Index
Name
Age
Department
1
John
28
Engineering
2
Jane
32
Product
3
Mike
25
Design
4
Sarah
30
Operations
5
Tom W.
27
Marketing
6
David S.
35
HR
Drag to Reorder Rows

Custom Drag Handle

Specify the CSS selector of the drag handle via drag-config.handle. Dragging is only triggered within the handle area to prevent accidental operations.

Index
Task Name
Priority
Status
1
Requirement Review
High
In Progress
2
UI Design
High
Completed
3
Frontend Dev
Medium
Pending
4
Backend Dev
Medium
Pending
5
Testing
Low
Pending
6
Deployment
Low
Pending
Drag Handle

Frozen Columns + Drag

Row dragging can be used in conjunction with frozen columns (fixed).

ID
Name
Department
Position
Salary
City
Phone
1
John
Engineering
Frontend Engineer
15000
Beijing
13800001111
2
Jane
Product
Product Manager
18000
Shanghai
13800002222
3
Mike
Design
UI Designer
14000
Guangzhou
13800003333
4
Sarah
Operations
Operations Director
22000
Shenzhen
13800004444
5
Tom W.
Marketing
Marketing Manager
16000
Hangzhou
13800005555
Frozen Columns + Row Drag

Drag Events

Obtain drag state information through the onDragStart and onDragEnd callbacks of drag-config, or by listening to the drag-end event.

Order
Name
ID
1
Item 1
1
2
Item 2
2
3
Item 3
3
4
Item 4
4
5
Item 5
5

Event Log:

Drag a row to view the event log

Drag Events

Tree Data Drag

Row dragging can be used with tree data (tree-config), supporting drag-and-drop tree nodes to adjust the order.

Name
Owner
Engineering
CEO Zhang
Frontend Team
Team Leader Li
John
Jane
Backend Team
Team Leader Wang
Mike
Sarah
Product
CEO Liu
Product Team 1
Team Leader Chen
Product Team 2
Team Leader Huang
Tree Data Drag

API

DragConfig

Passed through the drag-config property.

PropertyDescriptionTypeDefault
rowWhether row dragging is enabledbooleanfalse
columnWhether column dragging is enabledbooleanfalse
handleCSS selector for the drag handlestring
animationAnimation duration (ms)number150
onDragStartDrag start callback({ type, data, index }) => void
onDragEndDrag end callback({ type, oldIndex, newIndex, data }) => void
crossTableWhether cross-table dragging is supportedbooleanfalse
dragClassStyle class during draggingstring
ghostClassGhost element style classstring

Events

EventDescriptionParameters
drag-endTriggered when dragging ends{ type: 'row' | 'column', oldIndex: number, newIndex: number, data: unknown[] }

onDragStart Parameters

ParameterDescriptionType
typeDrag type'row' | 'column'
dataDragged recordunknown
indexDragged indexnumber

onDragEnd Parameters

ParameterDescriptionType
typeDrag type'row' | 'column'
oldIndexOriginal indexnumber
newIndexNew indexnumber
dataData after drag (reordered array)unknown[]

Released under the MIT License.