@felix wrote:
Hello,
if the data underlying a node in a palette contains an array, and two instances of that node are dropped from the palette into the main diagram, then the arrays do not necessarily receive unique
__gohashids, meaning that when using a binding to edit the values of elements in that list (via aTextBlockin anitemTemplate), a single edit may propagate to multiple nodes.Here's a MWE.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <script type="text/javascript" src="go-debug.js"></script> </head> <body> <div id="someDiv" style="border: solid 1px black; width:960px; height:640px"></div> <div id="paletteDiv" style="border: solid 1px black; width:960px; height:128px"></div> <script type="text/javascript" src="striptest.js"></script> </body> </html>
striptest.jsvar GO = go.GraphObject.make; function init() { myDiagram = GO(go.Diagram, "someDiv", { initialContentAlignment: go.Spot.Center, allowDrop: true } ) myDiagram.nodeTemplateMap.add("test", GO(go.Node, "Auto", GO(go.Shape, "Rectangle", {fill:"white"}) ,GO(go.Panel, "Vertical" ,GO(go.TextBlock, new go.Binding("text").makeTwoWay(), {editable:true}) ,GO(go.Panel, "Table" ,new go.Binding("itemArray","xx") ,{ itemTemplate: GO(go.Panel, "TableRow" ,GO(go.TextBlock, new go.Binding("text","a").makeTwoWay(), {editable:true}) ) } ) ) ) ) myPalette = GO(go.Palette, "paletteDiv", { initialContentAlignment: go.Spot.Center, // center the content nodeTemplateMap: myDiagram.nodeTemplateMap, // share the templates used by myDiagram model: new go.GraphLinksModel([ // specify the contents of the Palette { category: "test", text: "hello", xx:[{"a":1},{"a":2}] } ]) } ) } init()Drop two nodes onto the main diagram, and edit the text (works as expected) or edit a number (values are changed in both nodes). I think this is a bug.
This is quite a headache for me. Is this a problem you could address?
Posts: 5
Participants: 2