Hi @walter , I have two questions now…
- IS THIS APPROACH FINE
I am not calling Model.toJson, I am creating the diagram.model using below snippet
diagram.model = $(GraphLinksModel,
{
nodeDataArray: model.nodes, // 'model' is json object used to preload my json or to save json after update as it works by reference
linkDataArray: model.edges,
...options,
}
);
So whenever there is an update in diagram.model my “model” json is also getting updated without any “.toJson()” so i wrote converter function in binding like this and it is working.
new go.Binding("points").makeTwoWay(e=>{let it = e.iterator;
let res = [];
while (it.next()) {
let ps = go.Point.stringify(it.value);
var psa = ps.split(' ');
res = res.concat(psa);
}
return res})
- Why ModelChanged event is getting triggered in this scenario
when I load the diagram for the first time, with points two way binding on edge and points array present in my model json along with isLayoutPositioned as false… Model_Changed event is getting triggered for points value change and event.oldValue and event.newValue are same. It ends up triggering a transaction complete model changed event with incrementaldata as below.
{
"class": "GraphLinksModel",
"incremental": 1,
"nodeCategoryProperty": "templateId",
"linkCategoryProperty": "templateId",
"linkFromPortIdProperty": "fromPort",
"linkToPortIdProperty": "toPort",
"modelData": {},
"modifiedLinkData": [
{
"from_port": "49de92bc535c20100b0cddeeff7b12f9",
"points": [
"-200.130859375",
"268.26153564453125",
"-200.130859375",
"258.26153564453125",
"-200.130859375",
"257.412353515625",
"-161.5633544921875",
"257.412353515625",
"-161.5633544921875",
"256.56317138671875",
"-161.5633544921875",
"246.56317138671875"
],
"isLayoutPositioned": false,
"from": "0734148b-6638-48c8-8ed2-860c4216248f",
"to": "8ca73f32-5f49-4400-a4a2-1166a14aea0f",
"edge_id": "539bb9bb532310100b0cddeeff7b1207",
"templateId": "c98b79bb532310100b0cddeeff7b1200",
"fromPort": "49de92bc535c20100b0cddeeff7b12f9",
"interactiveGraphObjects": [
{
"name": "addNodeButton",
"ariaLabel": "Opens action picker to add a new node to the diagram",
"tabClickHandler": null
},
{
"name": null,
"ariaLabel": "Add a node",
"tabClickHandler": null
}
],
"recenterHandler": null
}
]
}