ng2-tree icon indicating copy to clipboard operation
ng2-tree copied to clipboard

Root Element did not have Treecontroller

Open badframe opened this issue 6 years ago • 5 comments

Because the Root element Did not have Treecontroller, It is not possible to select it by using "getControllerByNodeId()", and then It is not possible to use "addChild" for root node.

in debugger: (File: tree.service.js)

1. TreeService.prototype.getController = function (id) {
2.        if (this.controllers.has(id)) {
3.            return this.controllers.get(id);
4.        }
5.        return null;
6.    };

dump of "this.controller" (Line2) indicate a list of all nodes in tree with a Treecontroller except the root node!!!

badframe avatar Jan 31 '18 01:01 badframe

@badframe I noticed the same thing. I use a workaround by getting to the root controller via:

TreeComponent.rootComponent.controller

A bit hacky, but it works. It would be better, of course, if we could get to the root controller using the same function as other nodes.

dpollastrini avatar Jan 31 '18 01:01 dpollastrini

@badframe @dpollastrini Are you sure you actually have an id assigned to the root node?

rychkog avatar Feb 11 '18 15:02 rychkog

@rychcog Yes. Value was 0.

dpollastrini avatar Feb 12 '18 14:02 dpollastrini

@dpollastrini I'll try this value (zero). But I wasn't able to reproduce. Could you try another id (some string value for example)?

rychkog avatar Feb 12 '18 15:02 rychkog

Don't use "getControllerByNodeId()", use "getController()"

FelipeMuneraS avatar Nov 01 '18 16:11 FelipeMuneraS