Old context menu items override new context menu items.

Hello Syncfusion Team,

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

When user exits the app, we save the user's diagram using the .SaveDiagram() method and the resulting JSON is saved to our db. 

Later, when the user re-logs into the app, we load call the .LoadDiagram() method to load the user's diagram from the saved JSON.

In between however, if we make any app updates (e.g. introduce a new diagram context menu item), these updates are ignored/overwritten when we load the diagram from JSON (which still has the old diagram context menu items). 


I have prepared a stackblitz to demonstrate the issue.

The user's saved diagram json has 'old-menu-item' in the diagram's context menu.

The app has been upgraded to use 'new-menu-item'.

When we load the diagram from saved JSON, the 'new-menu-item' is ignored/overwritten by `old-menu-item'. 


Please let me know if a work around exists for this. 

Is there a way to suppress context menu items from being serialized into the JSON when calling .SaveDiagram()?



Thanks,
-Mithun

3 Replies

SG Shyam G Syncfusion Team December 4, 2019 10:14 AM UTC

Hi Mithun, 

Before loading a diagram, we should define a new context menu items to achieve your requirement. Please refer to a code example and sample below. 

Code example: 
onCreated() { 
    let parsedData = JSON.parse(diagramContent); 
    //create a new context menu item 
    parsedData.contextMenuSettings = { 
      show: true, 
      showCustomMenuOnly: true, 
      items: [ 
        { 
          id: 'new-menu-item', 
          text: 'new-menu-item', 
        } 
      ], 
    } 
    //load a diagram 
    this.diagramControl.loadDiagram(JSON.stringify(parsedData)); 
  } 
 


Regards, 
Shyam G 



MI Mithun December 4, 2019 10:48 AM UTC

Thank you. This is a very elegant solution.

Thanks,
Mithun



SG Shyam G Syncfusion Team December 4, 2019 11:02 AM UTC

Hi Mithun, 
Thanks for your update. 
Regards, 
Shyam G 


Loader.
Up arrow icon