How to restrict the child node dragging whereas allow group dragging
var nodes = [ { id: "node1", width: 50, height: 50, offsetX: 100, offsetY: 100, annotations: [{ content: "Seat1" }] }, { id: "node2", width: 50, height: 50, offsetX: 200, offsetY: 100, annotations: [{ content: "Seat2" }] }, { id: "node3", width: 50, height: 50, offsetX: 100, offsetY: 200, annotations: [{ content: "Seat3" }] }, { id: "node4", width: 50, height: 50, offsetX: 200, offsetY: 200, annotations: [{ content: "Seat4" }] }, { id: "group", children: ['node1', 'node2', 'node3', 'node4'] }, ]; |
//To disable drag constraints for child nodes in group node function selectionChange(args) { let node; if ((args.newValue[0]) && (args.newValue[0]).children !== undefined) { const group = args.newValue[0]; if (group.children) { group.constraints = ej.diagrams.NodeConstraints.Default for (var i = 0; i < group.children.length; i++) { node = diagram.getObject(group.children[i]); if (node.constraints) { node.constraints = ej.diagrams.NodeConstraints.Default; } } } } else if (!(args.newValue[0].children)) { (args.newValue[0]).constraints = ej.diagrams.NodeConstraints.Select | ej.diagrams.NodeConstraints.Drag; } } |
Conclusion
I hope you enjoyed learning about how to restrict the child node dragging whereas allow group dragging.
You can refer to our JavaScript Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for 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!