How to make diagram read-only but allow node selection/click

I need to make diagram read only but allow selection or at least a click event of a node.  I'm using the following options currently without any success:


diagram.constraints = DiagramConstraints.None;

diagram.tool = DiagramTools.None | DiagramTools.SingleSelect;


Please advise ?


1 Reply

VG Vivisa Ganesan Syncfusion Team June 20, 2023 12:10 PM UTC

Hi,

We have created the sample as per your requirement. To enable the node selection alone, you can eliminate other interactive constraints such as dragging, rotating, and resizing from the node’s default constraints. Please refer the code snippet below,

Code-snippet:

function getNodeDefaults(node: NodeModel): NodeModel {

  node.constraints =

    NodeConstraints.Default &

    ~(

      NodeConstraints.Drag |

      NodeConstraints.Delete |

      NodeConstraints.Resize |

      NodeConstraints.Rotate

    );

  return node;

}

 


Sample:

https://stackblitz.com/edit/mo19ff-8ly7wg?file=index.ts,index.html

Documentation:

https://ej2.syncfusion.com/documentation/diagram/constraints/

Regards,

Vivisa


Loader.
Up arrow icon