javascript - How to use drag and drop functionality both columns and rows in my React Table - ReactJS - Stack Overflow

I have created a table in React Table. I want to add both drag and drop functionality on columns and ro

I have created a table in React Table. I want to add both drag and drop functionality on columns and rows. How can I do this?

Here is my CodeSandbox Sample -

Here I have got a Code Sandbox for drag and drop rows -

Here I have got a Code Sandbox for drag and drop columns -

Being a beginner In React, I'm not able to integrate this three sandboxes. Can someone fork a good example on CodeSandbox on how to add both drag and drop functionality on columns and rows?

Please use my React Table data columns -

I have created a table in React Table. I want to add both drag and drop functionality on columns and rows. How can I do this?

Here is my CodeSandbox Sample - https://codesandbox.io/s/2wp7jk23kr

Here I have got a Code Sandbox for drag and drop rows - https://codesandbox.io/s/1844xzjvp7

Here I have got a Code Sandbox for drag and drop columns - https://codesandbox.io/s/5vxlnjrw1n

Being a beginner In React, I'm not able to integrate this three sandboxes. Can someone fork a good example on CodeSandbox on how to add both drag and drop functionality on columns and rows?

Please use my React Table data columns - https://codesandbox.io/s/2wp7jk23kr

Share Improve this question edited Oct 16, 2019 at 9:27 Sergey 1,0754 gold badges15 silver badges33 bronze badges asked Dec 17, 2018 at 3:25 tommy123tommy123 5871 gold badge11 silver badges28 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

It's not that hard to make it, but still no convenient way yet, I had a try and let's see the result in sandbox: https://codesandbox.io/s/quizzical-leakey-o5h8z

Then let's see what's going on in Table.js

1.When you start dragging, you do not know which direction it is going, so I just hide the snippet (by setting it to empty div)

2.When you first drag it into another cell I got to know the direction, and then lock the direction inside dragState.direction

3.When you drag it into an cell (including first time in step 2), you need to show the changed data, like rows = offsetIndex(dragState.row, dragState.dropIndex, rows), notice it is different depends on dragState.direction

4.We highlight the row/column we are dragging, with opacity: ....

5.Finally on dragEnd we notify parent ponent what have changed

It's not good enough yet, specially when the drag is cancled. So don't rely on these code too much, find your own way based on this idea

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744204249a4563023.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信