@jothibaskaran wrote:
Hi,
I want to create unique names by appending a count of similar nodes to the component name. This is the binding function:
new go.Binding('text', '', (data) => { let sameObjArray = []; this.diagram.model.nodeDataArray.forEach(element => { if (element['text'] == data.text && data.text == data.componentName) { sameObjArray.push(element); } }); let count = sameObjArray.length; if (count == 0) { return data.componentName; } else { while (_.find(sameObjArray, { 'componentName': data.componentName + Math.abs(count) }) != undefined) { count++; } return data.componentName + Math.abs(count); } }),This is the scenario for which it is not working:
- I drag node “Comp1” on to diagram.
- Drag the next node which is then “Comp2”
- Next I delete the node “Comp1”
- When i drag the next node, i expect it to be “Comp3”.
But, for some reason, it does show the name as “Comp3”, but the model data still has the name “Comp2”I cant really understand what is going on. Could you tell me how to resolve this?
Posts: 1
Participants: 1