Drag to another div which is not a datatable

Drag to another div which is not a datatable

jeffparnaujeffparnau Posts: 6Questions: 2Answers: 0

I need to drag from datatables to a location in another div. The target div contains possibly hundreds of smaller divs. I would like to replace the cursor with an image which I will create dynamically. I know how to create a draggable div, but I have not seen examples of dragging to a non-datables destination. Is it possible?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768
    edited April 2019

    I created a couple examples of drag and drop between tables; One using jQueryUI and the other using HTML5. Although I haven't tried it I suspect you can drop wherever you define.

    Feel free to update one or both examples with dragging to non-Datatable destinations. That way, although outside of the scope of Datatables, we can try to help if needed.

    Kevin

  • jeffparnaujeffparnau Posts: 6Questions: 2Answers: 0

    I did look at several examples of copying a row to another table. Ideally, what I am trying to do is partly answered here:

    http://jsfiddle.net/jeffparnau/x4ec7p38/30/

    That fiddle creates a div on mousedown, and immediately triggers the drag event (I haven't yet figured out how to capture the drop event).

    I need to achieve that same sort of action on datables' cell mousedown -- probably restricted to a cell dedicated to calling for the drag. The user would drop it into another separate div. BTW, I need to create the div at a certain size because its valid drop locations will be restricted based on its shape, which is defined in hidden "width" and "height" columns. (I can handle the size stuff on my own. Jut need lots of help getting the basic drag functions working.)

  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768

    Not sure about your example but it does look like you are using jQuery UI drag and drop. I updated my example to show one way of dragging from a Datatable to a div.
    https://jsbin.com/ruzakejewe/1/edit?js,output

    Not sure if its the best practice way to use jQuery UI drag and drop but it does show that it can work.

    Kevin

  • jeffparnaujeffparnau Posts: 6Questions: 2Answers: 0

    Here's what I see when I view your example. What am I doing wrong?

  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768
    edited April 2019 Answer ✓

    Try this link instead
    https://jsbin.com/yozagilapo/1/edit?js,output

    Kevin

  • jeffparnaujeffparnau Posts: 6Questions: 2Answers: 0

    Thanks so much. Perfect! This really had me stumped.

This discussion has been closed.