expand not working on first time
See original GitHub issueHi,
When adding a new node to tree it is not expanding when the parent node has been empty, but when there are children then it works. See the video: https://www.useloom.com/share/ce8709b4a27448e7a2eb0f56bbc92ad2
addLevel(parent) {
let newLevel = {
level_id: parent.data.id,
name: parent.data.name + " copy",
};
this.levelService.addLevel(newLevel)
.then(level => {
parent.data.children = parent.data.children || [];
parent.data.children.push(level.data);
this.tree.treeModel.update();
parent.expand();
});
}
<tree-root [nodes]="levels" [options]="treeOptions"
(moveNode)="onMoveNode($event)"
(activate)="onActivate($event)"
(deactivate)="onDeactivate($event)"
(event)="onEvent($event)"
>
<ng-template #treeNodeTemplate let-node="node" let-index="index">
<div class="level">
{{ node.data.name }}
<button class="btn btn-sm btn-success float-right" (click)="addLevel(node)"><i class="fa fa-plus"></i></button>
</div>
</ng-template>
</tree-root>
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
expand not working on first time · Issue #513 - GitHub
Hi, When adding a new node to tree it is not expanding when the parent node has been empty, but when there are...
Read more >Making a menu with collapse and expand... not working
Using flexbox to display the menu in a row when the screen is bigger. Once it hits the breakpoint, display the hamb icon....
Read more >Excel Table Does Not Expand for New Data - Contextures Blog
If you notice that Excel tables don't automatically expand on your computer, to include new data, there might be a problem with the...
Read more >Expand/collapse problem - JavaScript - SitePoint Forums
Some time ago, if I remember thanks to you, I made a new expand/collapse solution in js and css. The js is: $(".expandable").on("click" ......
Read more >expand / collapse doesn't work on heading if it's set later
docx file, in the start I choose H1 I type my Heading, and then I press enter. Now there are two sides to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is what worked for me
It looks like you have to use one of the angular lifecycle after the view is rendered. Then inside there you can get the treeModel to get the node by id and call expand().
Closing this issue due to inactivity. Please open a new issue if the problem still exists.