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

Adding/removing nodes from group from code

Hello,

We try to use the grouping-possibilities in the ejDiagram.
We would like to be able to drag an drop nodes in and out a group, but also we would like to add nodes to an existing group from code.
By dragging and dropping it works to add and remove nodes from a group, but we cannot find a way to add and remove nodes from code (e.g. on a click of a button).
Could you please tell us how this can be done?

An example of groups and nodes (and a testbutton with some experiments) is build here: http://jsplayground.syncfusion.com/vtmx32hf

Best regards,
Tycho

3 Replies

SG Shyam G Syncfusion Team August 17, 2016 07:24 AM UTC

Hi Tycho, 

Please use diagram’s client side method add to add the nodes at runtime and remove method to remove the nodes at runtime. We have created a JSPlayground link to achieve your requirement. 


Also you need to set the marginTop and marginleft for the containers children instead of offsetX and offsetY properties to position the children in the container. 

Regards, 
Shyam G 



TY Tycho August 17, 2016 08:02 AM UTC

Hi Shyam,

Thanks for your explanation. This is very usable to place a new node in a group.
Does this mean that inserting an existing node inside an existing group (or remove node from group without deleting it) is not possible (like what happens with drag and drop)?
I could imagine that with the method 'updatenode' its parent-property could be set?
By the way: at once the method 'groupChange' started firing; it did not do so before. Because you updated the version?

Best regards,
Tycho



SG Shyam G Syncfusion Team August 18, 2016 06:01 AM UTC

Hi Tycho, 

We have created a sample to achieve your requirement and it is available in the below link for download. 


Regards, 
Shyam G 


Loader.
Up arrow icon