Drag and Drop Root Test
I've gotten the node moving working!
What is the best way to test if they've dragged the node to the root of the tree? I've just added the data.virtual check so it can set the parent id to null ( no parent, it is at the root ). Is that correct?
onMoveNode($event) {
let child: Page = $event.node;
let parent: Page = $event.to.node.data;
if ($event.to.node.data.virtual) // Root
child.parentId = null;
else
child.parentId = parent.id;
this.pageService.saveTree(this.nodes)
.then(result => this.nodes = result);
}
Yes that's correct, or just check if it doesn't have parent:
if (!$event.to.node.parent)
Yes that's correct, or just check if it doesn't have parent:
if (!$event.to.node.parent)
- Adam Klein http://il.linkedin.com/in/adamklein500
- CTO @ 500Tech.com http://500tech.com/
- AngularJS, ReactJS, NodeJS
- Development, consulting, training and public speaking
- (+972) 52 747 5633
On Fri, Oct 21, 2016 at 12:20 PM, Leah [email protected] wrote:
I've gotten the node moving working!
What is the best way to test if they've dragged the node to the root of the tree? I've just added the data.virtual check so it can set the parent id to null ( no parent, it is at the root ). Is that correct?
onMoveNode($event) {
let child: Page = $event.node; let parent: Page = $event.to.node.data; if ($event.to.node.data.virtual) // Root child.parentId = null; else child.parentId = parent.id; this.pageService.saveTree(this.nodes) .then(result => this.nodes = result);}
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/500tech/angular2-tree-component/issues/86, or mute the thread https://github.com/notifications/unsubscribe-auth/AA2SSjo6nyhDYFMNzBed3NKbpbtskcaWks5q2IPDgaJpZM4KdBqC .