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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

The 'collectionChange' event is not triggered when nodes are ungrouped.

Thread ID:

Created:

Updated:

Platform:

Replies:

149685 Dec 5,2019 11:53 AM UTC Dec 9,2019 04:21 AM UTC Angular - EJ 2 3
loading
Tags: Diagram
Mithun
Asked On December 5, 2019 11:53 AM UTC

Hello Syncfusion Team,

Our app uses Syncfusion's DiagramComponent ("@syncfusion/ej2-angular-diagrams": "^17.3.26").

In our app, we'd like to save the user's diagram whenever the user groups or ungroups nodes.

We received the collectionChange event when nodes are grouped together.

However no events are seemingly triggered when the grouped nodes are ungrouped. 

I have a stackblitz demo here (please see the console log there): https://stackblitz.com/edit/diagram-ungroup-no-event

Is this a bug or am I doing something wrong?

Thanks,
Mithun

Shyam G [Syncfusion]
Replied On December 6, 2019 06:09 AM UTC

Hi Mithun, 

Please use historyChange event to track the group/ungroup action. Please refer to a code example and modified sample below. 

Code example: 
//inject undo redo module  
Diagram.Inject(UndoRedo) 

<ejs-diagram #diagramControl id="diagram-control" 
      width="100%" height="500px" 
      [contextMenuSettings]="this.contextMenuSettings" 
      (collectionChange)="onCollectionChange($event)" 
      (historyChange)="onHistoryChange($event)"  
      (created)="onCreated()"> 
    </ejs-diagram> 

onHistoryChange(args: IHistoryChangeArgs) {  
    if((args.change as any).type === 'Group' || (args.change as any).type === 'UnGroup') { 
        console.log(`historychange`); 
   
 





Regards, 
Shyam G 


Mithun
Replied On December 6, 2019 08:50 AM UTC

Thanks Shyam. That worked! 

A small concern though... 

(args.change as any).type === 'Group'

The '.type' property does not seem to be a publicly documented property of  'SelectorModel' (which is the type of args.change).

Just want to future-proof my solution so there are no inadvertent breaking changes in future. 

Thanks,
-Mithun




Shyam G [Syncfusion]
Replied On December 9, 2019 04:21 AM UTC

Hi Mithun, 

Sorry for the inconvenience. 

To achieve your requirement, we use interface to implement the type. Please refer to a code example and sample below. 

Code example: 
interface IHistory { 
  type: string 

onHistoryChange(args: IHistoryChangeArgs) {   
    if((args.change as IHistory).type === 'Group' || (args.change as IHistory).type === 'UnGroup') { 
        console.log(`historychange`); 
   
  }  



Regards, 
Shyam G 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon