How to Trigger Event When Diagram is in Read-Only Mode in Vue Diagram?
This article explains how to trigger an event when a diagram is in read-only mode in Vue Diagram.
In Syncfusion® Vue Diagram, you can make the diagram read-only while still triggering events like click by disabling the select constraints on nodes and connectors, along with the zoom constraint on the diagram. This effectively prevents interactions such as selection and zooming. The getNodeDefaults method uses NodeConstraints to disable the selection functionality on nodes, while the getConnectorDefaults method uses ConnectorConstraints to disable the selection functionality on connectors. Additionally, the DiagramConstraints disable the zoom functionality in diagram.
The following code snippet demonstrates how to configure these settings and trigger the click event.
data: function() {
return {
// Diagram properties
width: "100%",
height: "645px",
nodes: nodes,
connectors: connections,
// Disable the Zoom constraint for diagram
constraints: (DiagramConstraints.Default & ~DiagramConstraints.Zoom),
// Disable the Select constraint for nodes
getNodeDefaults: (obj) => {
obj.width = 100;
obj.height = 100;
obj.constraints =
NodeConstraints.Default & ~NodeConstraints.Select;
return obj;
},
// Disable the Select constraint for connectors
getConnectorDefaults: (connector) => {
connector.constraints = ConnectorConstraints.Default & ~ConnectorConstraints.Select;
return { style: { strokeColor: "#024249", strokeWidth: 2 } };
},
// Define the click event
click: () => {
alert('Click Event is triggered');
}
};
},
Refer to the working sample for additional details and implementation: Click here for sample
Conclusion
We hope you enjoyed learning how to trigger the click event when the diagram is in read-only mode 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, BoldDesk Support, or feedback portal. We are always happy to assist you!