Articles in this section
Category / Section

How to Disable and Enable Editing Button Click in JavaScript Diagram?

2 mins read

To control the behaviors of the JavaScript Diagram, nodes and connectors, you can use constraints. DiagramConstraints allow you to enable or disable various behaviors, such as: page editing, bridging, zoom and pan, undo/redo, and tooltips.

If you want to enable or disable editing in the diagram with button click, you can toggle the DiagramConstraints.PageEditable property.This will allow you to switch between enabling or disabling page editing dynamically.

Here’s an example of how to enable or disable page editing using the diagram’s constraints
You need to add buttons in your template to toggle the editing of the diagram

<input type="button" value="enable Editing" id="enable" />
   <input type="button" value="disable Editing" id="disable" /> 
document.getElementById('enable').onclick = function() {
     diagram.constraints = ej.diagrams.DiagramConstraints.Default;
 };
 document.getElementById('disable').onclick = function() {
     diagram.constraints = ej.diagrams.DiagramConstraints.Default &~ ej.diagrams.DiagramConstraints.PageEditable;
 }; 

Sample

Conclusion

I hope you enjoyed learning how to enable and disable editing with a button click in the JavaScript Diagram.
You can refer to our JavaScript Diagram feature tour page to learn about its other groundbreaking features 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)
Please  to leave a comment
Access denied
Access denied