But when I try to bind a TextBlock’s text property in a node template to the element.name property in my node data ($(go.TextBlock, new go.Binding(“text”, “element.name”))), there is nothing displayed in that node.
Presumably, it is not possible to bind with an “a.b” notation, although I did not see anything related to this in your documentation.
Would you have any recommendation as to how how could make this work (using a two-way binding especially)? Or is there no choice and the node data to be bound to needs to be flat?
If you want to make programmatic changes to the model data, you can do:
var data = myDiagram.model.findNodeDataForKey("1"); // or however you want to get that node data
myDiagram.model.setDataProperty(data.element, "text", "XYZ");
myDiagram.model.updateTargetBindings(data, "element");
Of course the above code needs to be executed inside a transaction, especially if you want to support undo and redo.
You are right that using “”, referring to the whole data object, as the source “property” does slow down binding evaluations. Often that doesn’t matter much, but maybe it would if you are updating it continuously and there are a lot of bindings on unrelated bits of state.