Hi Federica Chiuchiarelli,
We have created a sample to get the parent of the selected node. When we select or deselect any nodes or connectors in diagram, the "SelectionChange" event is triggered. By using the SelectionChangeEventArgs we can get the selected node inconnect and out connect edges. By using those inconnect edges we can find the source node(parent) of the connector. By using the source node(parent), we can able to modify the parent node’s fill and background color until the root. Please find the below code snippet for how to use the selectionChange event and how to change the style for parent node.
|
diagram.selectionChange = function (args) {
if (args.state == "Changed") {
if (args.type == "Addition") {
if (args.oldValue.length > 0) {
var oldNode = diagram.getObject(args.oldValue[0].id);
styleChanged(oldNode, '#659be5', 1);
diagram.dataBind();
}
if (args.newValue.length > 0) {
var newNode = diagram.getObject(args.newValue[0].id);
styleChanged(newNode, '#6FAAB0', 3);
}
} else if (args.type == "Removal" && args.oldValue.length > 0) {
var oldNode = diagram.getObject(args.oldValue[0].id);
styleChanged(oldNode, '#659be5', 1);
diagram.dataBind();
}
}
} |
For more information about selectionChangeEvent, please find the below help documentation link:
We have created a sample for your requirement. Please find the sample in below link
Regards,
Suganthi K.