I have a backend which generates node data and link data. I am wondering if there is a way I can bind a custom property or already available property to set some specific nodes, i.e., to highlight them. For example, if I can send this node data array {‘key’: index, ‘text’: ‘isHighlighted’: true}. Once the frontend receives this data, all nodes with ``isHighlighted’’ property as true will be highlighted/selected. Next, when I click the background anywhere, all nodes should be unhighlighted/deselected. I guess I have figured out how to unhighlight or deselect the nodes based on a mouse click in the background but I am unable to achieve the first step, i.e., setting highlight or select property while defining the node data itself.
I think you can implement this using a simple Binding on your node template:
new go.Binding("isHighlighted").makeTwoWay()
To implement a background click that un-highlights everything:
$(go.Diagram, . . .,
{ . . .
click: function(e) { // a click in the background, not on a Part
if (e.diagram.highlighteds.count > 0) {
e.diagram.commit(function(diag) { diag.clearHighlighteds(); });
}
}
})