@Curry wrote:
Hello,
I use GoJS and the TreeModel.
Each node in my tree has a property called "level" that simply is a number that shows its level in the tree. When I move a sub-graph the value of this "level" should get adjusted in all nodes of that sub-graph. How to do it?
I have this inside a mouseDrop-Function:
var diagram = node.diagram; var selnode = diagram.selection.first(); // assume just one Node in selection if (mayWorkFor(selnode, node)) { diagram.model.startTransaction("adjust level of all nodes under the Selected Node"); var itr = selnode.findNodesOutOf(); while (itr.next()) { var nodeN = itr.value; // here I need: var nodeNadjustedLevel = find out the level-value of the nodeN diagram.model.setDataProperty(nodeN.data, 'level', nodeNadjustedLevel); } diagram.model.commitTransaction("adjust level of all nodes under the Selected Node");}
selnode is the node that gets moved. If selnode has a sub-graph hanging under it then this sub-graph moves along with it --> all its nodes should get the adjustment of their "level" property.
Posts: 2
Participants: 2