How to Update Node and Treeview Content at Runtime in Vue Diagram?
The TreeView component is a graphical control that displays a hierarchical structure of nodes. Syncfusion® provides support for TreeView in Vue 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
id="dialog"
ref="dialog"
:visible="false"
:width="200"
:height="200"
:beforeOpen="resetInputValue"
:footerTemplate="'footerTemplate'"
:showCloseIcon="true"
>
<template v-slot:footerTemplate>
<div>
<input
v-model="inputValue"
class="e-input"
aria-label="Message"
type="text"
placeholder="Enter your node name here!"
/>
<button
@click="send"
class="e-control e-btn e-primary"
data-ripple="true"
>
Update
</button>
<button
@click="cancel"
class="e-control e-btn e-primary"
data-ripple="true"
>
Cancel
</button>
</div>
</template>
</ejs-dialog>
How to update the content of a node and TreeView.
- The dialog box will be triggered upon double-clicking the diagram nodes.
- Edit the input area of the dialog box, and by using the Update button, we can update both the nodes and TreeView content.
send() {
let content = this.inputValue;
diagramInstance.selectedItems.nodes[0].annotations[0].content = content;
let data = workingData;
let treeview = treeObj;
let elementNodeId = diagramInstance.selectedItems.nodes[0].id;
let tempData = data.filter((a) => a.Id === elementNodeId);
treeview.updateNode(tempData[0].Id, content);
diagramInstance.dataBind();
Dialog.visible = false;
},
Sample: Click Here
Conclusion
I hope you enjoyed learning how to update node and TreeView content at runtime in Vue Diagram.
You can refer to our Vue Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our Vue 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!