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
close icon

Copy and paste not always working with changed properties

Hello,

we have a problem when copying and pasting nodes and connectors after we change properties (color, annotations, addInfo data). When pasting all changes are lost. Note that we serialize the diagram and it is saved and reloaded correctly.

I've seen the same behavior (losing changes) in some examples in the website, while not in others.

Below is a screenshot from the latest example in the getting started page (https://ej2.syncfusion.com/angular/documentation/diagram/getting-started#create-an-angular-application)

Here I enlarged the first box, changed the label in "test", then copied and pasted it and the result is the original small box with "Elizabeth" label.

We are using Angular v12 and syncfusion ej2-angular-diagrams v20.1.

What is the correct way to copy the changed nodes and connectors?

Screenshot_20230202_180307.png



1 Reply

BM Balasubramanian Manikandan Syncfusion Team February 3, 2023 01:25 PM UTC

Use the doBinding function to set the annotations value to resolve your issue. In our getting started documentation,  they have used getNodeDefaults function which is triggered on adding node dynamically. So, the old annotation is preserved on copy and paste. We will update the documentation's getting started page, which will be reflected in the upcoming  volume 1 release, which is scheduled to release on March 2023. Refer to the below-mentioned code example and sample.


Code snippet:

   doBinding: (nodeModel: NodeModel, data: object, diagram: Diagram) => {

        nodeModel.shape = {

          type: 'Text',

          content: (data as EmployeeInfo).Name,

        };

        nodeModel.width = 80;

        nodeModel.height = 50;

        nodeModel.style = {

          fill: '#659be5',

          strokeColor: '#659be5',

          color: 'white',

          strokeWidth: 2,

        };

        nodeModel.borderColor = '#3a6eb5';

        nodeModel.backgroundColor = '#659be5';

      },


Sample:

https://stackblitz.com/edit/angular-ruv7j2-kc53lf?file=app.component.html


Loader.
Live Chat Icon For mobile
Up arrow icon