How to add a Vue Diagram group node in the symbol palette at run time?
This article explains how to add a Vue Diagram group node in the symbol palette at runtime. A group is used to cluster multiple nodes and connectors into a single element in a diagram. The child elements inside a group can be edited individually. Moreover, a group node can be seamlessly integrated into the symbol palette, providing users with the flexibility to drag and drop it onto the canvas multiple times. The following Vue Diagram code demonstrates how to dynamically add a group node, along with a regular node, to the symbol palette at runtime:
function addButton() {
let palette2 = [{ id: 'groupPalette', expanded: true, title: 'Group Nodes' }];
palette.addPalettes(palette2);
var nodes = diagram.nodes[4];
if (nodes.children) {
for (var i = 0; i < nodes.children.length; i++) {
var child1 = diagram.getObject(nodes.children[i]);
palette.addPaletteItem('groupPalette', child1, false);
palette.dataBind();
}
palette.addPaletteItem('groupPalette', nodes, false);
palette.dataBind();
}
}
In this code snippet, a new palette titled ‘Group Nodes’ is dynamically added to the symbol palette when a button is clicked. The group node and its children are then added as palette items using the addPaletteItem method. This method considers whether the item is a group node or a child, allowing for the appropriate addition to the palette. Finally, the dataBind method is invoked to apply any pending property changes immediately to the component.
For a hands-on demonstration, refer to the sample illustrating how to add a group node to the symbol palette at runtime with a button click.
Conclusion
We hope you enjoyed learning about how to add a group node in the symbol palette at runtime.
You can refer to our Vue Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, as well as how to quickly get started with configuration specifications. You can also explore our Vue 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!