@RakeshHarsha wrote:
Hi Walter,
Below is my requirement,
1) I have tree structure, based on click on the tree element, i need to create a new Layer(if there is no layer existing with the same name). And now i will be able to drag and drop elements from palette to the Layer(Diagram)
2) now, if i click on another tree element i need to again create a new Layer if there is no layer existing with the same name. But, the Elements which i have drawn on the previous layers should still be there.This can go on for n number of tree Elements.
I have tried as below
this.myDiagram.nodeTemplate = SCE(go.Part, // no links or grouping, so can use the simpler Part class new go.Binding("layerName", "StateMachine"), ); //Default Layer at the start this.myAppTreeView.addDiagramListener("ObjectSingleClicked", this.treeObjectSingleClicked); //Added a function for singleClick on Tree Element treeObjectSingleClicked = (ev) => { this.myDiagram.startTransaction("toggle layer visibility"); var lay = this.myDiagram.findLayer(this.selectedTreeNode); //selectedTreeNode is the tree element which is selectec var myD = this.myDiagram; if (!lay) { this.myDiagram.addLayerAfter($(go.Layer, { name: this.selectedTreeNode }), myDiagram.findLayer("")); } else { lay.visible = !lay.visible; } this.myDiagram.commitTransaction("toggle layer visibility"); }
The problem is, previously dragged and dropped nodes[elements/shapes] on a first layer is staying even though i have clicked on another tree element[for creating second layer].
i could see the layers are getting created as i could see the myDiagram.layer.count
Posts: 1
Participants: 1