question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Drag and Drop external Element -> Need better example

See original GitHub issue

I am trying to drag and drop external elements into the tree.

I have defined my external element like so:

<span [treeDrag]="{displayName: item.displayName}" [treeDragEnabled]="true">{{item.displayName}}</span>

But I get an error when dropping the element

screenshot 2017-04-14 02 26 24

EXCEPTION: Error in ./CreateTemplateComponent class CreateTemplateComponent - inline template:66:14 caused by: node.getIndexInParent is not a function

The docs suggest to implement a custom handler, but how should this handler look like?

You specify the element that will be reported as ‘from’ in actionMapping (instead of the node when dragging a tree node).

Does this mean I need to create a new TreeNode, add it to the tree, update the view and then move the node, so the tree kind of handles it like an internal drop (and not external)? It’s extremely confusing for me, can someone clarify?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
musti2commented, Feb 4, 2018

The so called ‘updated docs’ haven’t provided any clue as to what needs to happen to drag an external element into the tree.

Can someone please provide a better example?

2reactions
adamkleingitcommented, Apr 17, 2017

Hi,

I updated the docs.

You don’t need to create a new TreeNode. You need to update the original nodes structure and then call tree.update() on the tree.

Checkout the new docs: https://angular2-tree.readme.io/v3.3.0/docs/drag-drop

Read more comments on GitHub >

github_iconTop Results From Across the Web

Drag and Drop external Element -> Need better example #250
I am trying to drag and drop external elements into the tree. I have defined my external element like so:.
Read more >
Using the HTML5 Drag and Drop API - web.dev
The HTML5 Drag and Drop API means that we can make almost any element on our page draggable. In this post we'll explain...
Read more >
An Essential Guide to JavaScript Drag and Drop By Examples
This tutorial introduces you to the JavaScript Drag and Drop API and shows you how to handle drag and drop events effectively.
Read more >
Drag–and–Drop: How to Design for Ease of Use
This short animation gives a preview of what will happen when the cursor is released and makes the motion feel natural.
Read more >
HTML Drag and Drop API - MDN Web Docs
The user may select draggable elements with a mouse, drag those elements to a droppable element, and drop them by releasing the mouse...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found