Articles in this section

How to Update Node and Treeview Content in JavaScript Diagram?

The TreeView component is a graphical control that displays a hierarchical structure of nodes. Syncfusion® provides support for TreeView in JavaScript 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.

var dialog = new ej.popups.Dialog({
 footerTemplate: `<input id="inputValue" class="e-input" aria-label="Message" type="text" placeholder="Enter your node name here!"/>
       <button id="sendButton" class="e-control e-btn e-primary" data-ripple="true">Update</button>
       <button id="cancelButton" class="e-control e-btn e-primary" data-ripple="true" >Cancel</button>`,
 showCloseIcon: true,
 visible: false,
 width: '200',
 height: '200',
});

dialog.appendTo('#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.
function send() {
 let getContent = document.getElementById('inputValue');
 let content = getContent.value;
 diagram.selectedItems.nodes[0].annotations[0].content = content;
 let data = workingData;
 let treeview = treeObj;
 let elementNodeId = diagram.selectedItems.nodes[0].id;
 setTimeout(function () {
   let tempData = data.filter((a) => a.Id === elementNodeId);
   treeview.updateNode(tempData[0].Id, content);
 }, 0);
 diagram.dataBind();
 dialog.visible = false;
} 

Sample: Click Here

Conclusion
I hope you enjoyed learning how to set the position of a swimlane in JavaScript Diagram.

You can refer to our JavaScript Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our JavaScript 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)
Access denied
Access denied