Runtime Node Constraints

Is it possible to add node constraints at runtime?

I have tried the following but "NodeConstraints is not defined". Note, I have also tried "constraints: ~Drag" and both as lowercase also.

<script>
function addReportNode() {

            var diagram = $("#Diagram").ejDiagram("instance");

            // Defines JSON to create a node
            var reportNode = {
                name: "reportNode",
                offsetX: 550,
                offsetY: 240,
                height: 80,
                width: 200,
                fillColor: "rgb(75, 205, 150)",
                constraints: ~NodeConstraints.Drag,
                type: ej.datavisualization.Diagram.Shapes.Html,
                templateId: "htmlReportTemplate",
            };

            var connector = {
                sourceNode: "sourceNode",
                targetNode: "reportNode"
            }
            // Adds node to the Diagram
            diagram.add(reportNode);
            diagram.add(connector);
        }
</script>


1 Reply 1 reply marked as answer

AR Aravind Ravi Syncfusion Team July 23, 2020 05:28 AM UTC

Hi Dsoftware, 
 
To restrict the node drag , remove the drag constraints from the node Default constraints. On analyzing the provided code snippet , you have directly access the NodeConstraints, so that NodeConstraints of undefined error occurs. When try to access any diagram properties get the properties from the diagram and access the required property as  ej.datavisualization.Diagram.NodeConstraints. Please refer below code example 
 
var node = { 
            name: "newNode", 
            width: 100, 
            height: 100, 
 
            //Sets position 
            offsetX: 550, 
            offsetY: 100, 
            fillColor: "white", 
    borderWidth: 2, 
    constraints: ej.datavisualization.Diagram.NodeConstraints.Default & ~ej.datavisualization.Diagram.NodeConstraints.Drag 
        }; 
 
Regards 
Aravind Ravi 


Marked as answer
Loader.
Up arrow icon