Hi @walter,
I am trying to use a different approach to provide “Tree Like” view, where i am not using “TreeExpanderButton”. Instead, i added all the nodes, that need to be in the sub-tree, in the same “rows” model for “rowheaders” diagram and corresponding nodes in the main diagram on right hand side.
Also, i have used a “square” shape which i want to use as a button (Blue colored on left of “Task-33” and “Task-34” in “rowheaders” diagram).
Now, am trying to add a functionality to this button, where, if i click on this button, it will toggle the “visibility” of “sub-tree” nodes (nodes without blue square shape box on left with name “Constaint-Task-331”, “Constaint-Task-332”, “Constaint-Task-333”, etc).
Also, clicking on this button will toggle the “visibility” of corresponding “Red” colored nodes in the main diagram on the right hand side.
Currently, i am not able to toggle the visibility of nodes on either sides.
Also, when nodes are invisible/hidden, “Nodes” after them need to move up as well.
Could you please help me in this?
Thanks.
PS:
myRowHeaders =
$(go.Diagram, "myRowHeadersDiv",
{
isReadOnly: true,
"animationManager.isEnabled": false,
allowHorizontalScroll: false,
contentAlignment: go.Spot.TopCenter,
padding: 0,
"ViewportBoundsChanged": function(e) {
myDiagram.scale = e.diagram.scale;
myDiagram.position = new go.Point(myDiagram.viewportBounds.x, e.diagram.position.y);
},
nodeTemplate:
$(go.Part, "Auto", // don't need any links
{ width: 180, height: gridHeight, selectionAdorned: false },
new go.Binding("position", "row", function(row) { return new go.Point(0, convertRowToY(row)); }),
$(go.Shape, "Rectangle",
{ stroke: "black", strokeWidth: 1, portId: "", fromLinkable: false, toLinkable: false , fill : null}),
$(go.Panel, "Horizontal",
{ alignment: go.Spot.Left},
//Blue color shape to be used as button
$(go.Shape, "Square",
{
strokeWidth: 1,
name: "ECR",
desiredSize: new go.Size(15, 15),
fill: "white",
click: function (e, shape) {
var diagram = e.diagram;
// Toggling shape color
if (isTreeExpanded == true) {
isTreeExpanded = false;
shape.fill = "white";
}
else {
isTreeExpanded = true;
shape.fill = $(go.Brush, "Radial", { 0: "white", 1: "blue" });
}
}
},
// Remove shape from "sub-tree" nodes
new go.Binding("opacity", "",function(data) {
if (data.istask == true) {return 1;}
else {return 0;}
})),
$(go.TextBlock,
{ width: "100%", margin: 10, alignment: go.Spot.Center, verticalAlignment: go.Spot.Left },
new go.Binding("text"))
)
)
});