Open CatalinRadoi opened 5 years ago
https://github.com/dabeng/OrgChart/pull/398 might help you.
I created an application with a 'toolbox' at one side from which you could drag items (ul tags) into the chart. They would be inserted within the node you dragged to. Works on touch devices too.
Looks like @dabeng has committed my PR, so you should be able to do this now.
I was a little bit lazy in that I did not update any of the documentation or provide a JSFiddle example, but there is a new event you can attach to and pick up the 'drop' request from your code above into orgchart.
@richardwalker-iamtech A fiddle would be highly appreciated.
@richardwalker-iamtech A fiddle would be highly appreciated.
This was really bugging me, so I looked into commit 76797d5 which helped me figure out how to do this. My method could be wrong but it's working... Fiddle here: https://jsfiddle.net/acid9nine/wm81xtz0/
Sorry, this escaped my mind, and it has been ages since I used the code, so I am starting to forget the details!
@acidnine If you method works, then great! I think that the nodedrop.orgchart event was used to note the updates to the base data (from existing orgchart.js drag-and-drop) and keep my model up-to-date.
To aid for picking up drag-and-drops from other places (like your list), I added the event otherdropped.orgchart to orgchart.
I had something like:
$chart.on('otherdropped.orgchart', function (event) { var draggedData = event.draggedItem.attr('drag-me-data'); var droppedOnNodeId = event.dropZone.attr('id'); // todo: do something with the data, such as update your data model // need to maek sure draggedData and droppedOnNodeId are valid etc. }
Wow, thanks @richardwalker-iamtech I appreciate the explanation and like your method more, simplifies things further so elements don't have to have a faking node class/return false on drop. https://jsfiddle.net/b2e6cyn8/
Since examples of external drag/drop functionality have been given this can probably now be closed @CatalinRadoi ?
Hi! I have created an ul like this:
that's what I have in JS:
function drag(event) { console.log(event.target.id); console.log(event.target.innerHTML);
I would like to be able to drag an li from this list to the grid and get the id and innerHTML into the node.
I have no idea on how to accomplish that. And also, my grid has "draggable": true, because I also want to drag nodes in the org chart.
Any help will be greatly appreciated, thanks!