Articles in this section
Category / Section

How to Update Node and Treeview Content in Angular Diagram?

3 mins read

The TreeView component is a graphical control that displays a hierarchical structure of nodes. Syncfusion® provides support for TreeView in Angular Diagram.
To update Nodes and TreeView content at runtime, we can use the dialog component to update both nodes and TreeView nodes.

Define the Dialog component in the HTML.

<ejs-dialog
       #Dialog
       [width]="width"
       [height]="height"
       [visible]="false"
       [showCloseIcon]="showCloseIcon"
     >
       <ng-template #footerTemplate>
         <input
           id="inVal"
           #inVal
           class="e-input"
           aria-label="Message"
           type="text"
           placeholder="Enter your node name here!"
         />
         <button
           id="sendButton"
           (click)="send()"
           class="e-control e-btn e-primary sendButton"
           data-ripple="true"
         >
           Update
         </button>
         <button
           id="cancelButton"
           (click)="cancel()"
           class="e-control e-btn e-primary sendButton"
           data-ripple="true"
         >
           Cancel
         </button>
       </ng-template>
     </ejs-dialog> 

How to update the content of a node and TreeView.

  1. The dialog box will get triggered upon double-clicking the diagram nodes.
  2. Edit the input area of the dialog box, and by using the Update button, we can update both the nodes and TreeView content.
public send() {
   let getContent: any = document.getElementById('inVal');
   let content = getContent.value;
   this.diagram.selectedItems.nodes[0].annotations[0].content = content;
   let data: any = this.data1;
   let treeObj = this.treeview;
   let elementNodeId = this.diagram.selectedItems.nodes[0].id;
   setTimeout(function () {
     let tempData = data.filter((a: any) => a.Id === elementNodeId);
     treeObj.updateNode(tempData[0].Id, content);
   }, 0);
   this.diagram.dataBind();
   getContent.value = '';
   this.Dialog.visible = false;
 }

Sample: Click Here

Conclusion
I hope you enjoyed learning how to update node and treeview content in Angular Diagram.

You can refer to our Angular Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Angular Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied