We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Not allow the removal of certain nodes

Hi, I am looking into how to forbid the user on deleting certain nodes from the diagram.

I've tried setting theargs.cancelproperty to true in the collectionChange event but the node keeps getting deleted from the diagram.

I don't know where I should place the condition in order to let the user know that she can't delete the tried node.


1 Reply 1 reply marked as answer

BM Balasubramanian Manikandan Syncfusion Team November 15, 2022 12:57 PM UTC

In collectionChange event, you should set args.cancel to true when the state “Changing” to prevent deleting of nodes. Refer to the below mentioned code example and sample.


Code Example:

function collectionChange(args) {

  if (

    args.state == 'Changing' &&

    args.type == 'Removal' &&

    args.element.id == 'support'

  ) {

    args.cancel = true;

  }

}


Sample:

https://stackblitz.com/edit/tgqqv6-bf1dnw?file=index.html,index.js



Marked as answer
Loader.
Live Chat Icon For mobile
Up arrow icon