-
Notifications
You must be signed in to change notification settings - Fork 188
Closed
Description
i was reading the documentation and did fair amount of research but could not find a way to programatically deselect a node.
My Scenario:
When user 'left click' a node, a form template needs to show up right below the value. But since it is still part of the node, when user tries to click inside the form, the "node selection" event fires again, triggering the code to select node again.
my template:
<tree [tree]="tree" #treeComponent
(menuItemSelected)="onMenuItemSelected($event)"
(nodeMoved)="handleMoved($event)"
(nodeRenamed)="handleRenamed($event)"
(nodeRemoved)="handleRemoved($event)"
(nodeSelected)="handleSelected($event)"
(nodeCreated)="handleCreated($event)">
<ng-template let-node>
<p [ngClass]="{'wfTrigger-query': node.id === 'trigger'}" [innerHTML]="node.value"></p>
<div class="tree-form-container" *ngIf="node.showForm"> <-------- node.showForm is the flag
<div class="form-group">
<button type="button" class="close pull-right" aria-label="Close" (click)="handleClosingContent(node)">
<i class="fa fa-times"></i>
</button>
<div>
<input type="text" id="description" name="description" class="form-control" [(ngModel)]="node.value"/>
</div>
</div>
</div>
</ng-template>
</tree>
my component:
private handleSelected(e: any): void {
if (e && e.node && e.node.node && !e.node.node.showForm) {
e.node.node['showForm'] = true;
}
}
private handleClosingContent(node: any): void {
const oopNodeController = this.treeComponent.getControllerByNodeId(node.id);
if (node && node.showForm){
delete node['showForm'];
oopNodeController.deselect(); // looking for something like this as the 'handleSelected' is getting called again
}
}
by the way, thank you so much for a flexible yet powerful tree plugin.