Articles in this section

How to Update the Node Data at Runtime in Vue Diagram Layout?

The Vue Diagram allows you to dynamically update the node data in the layout (such as annotations or labels) at runtime. In this guide, we will demonstrate how to update the content of a selected node programmatically.

To modify the content of a node dynamically, you can use the content property of the node’s shape.

Below is a code example that shows how to update the node data at runtime when the Node Data button is clicked.

nodeData: function () {
// Check if any node is selected
     if (diagramInstance.selectedItems.nodes.length > 0) {
// Dynamically update the node content
       (diagramInstance.selectedItems.nodes[0].shape as any).content = 'Head of the board';
         diagramInstance.dataBind();
     }
   } 

Check for Selected Node: We use diagram.selectedItems.nodes.length to check if any node is selected in the diagram.

Update Node Content: If a node is selected, we modify the content property of the node’s shape. In this example, the content is set to ‘Head of the board’.

Sample:

Refer to the working sample for additional details and implementation: Stackblitz

Conclusion

We hope you enjoyed learning how to update the node data at runtime in the Vue Diagram layout.

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, BoldDesk Support, 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