@vertice wrote:
I am trying to capture TreeExpanded and TreeCollapsed events, but the respective listeners are not being called. I have implemented the listeners as follows:
myDiagram.addDiagramListener("TreeExpanded", function(e) { console.log(">>>>> STUFF HAPPENED in TreeExpanded"); }); myDiagram.addDiagramListener("TreeCollapsed", function(e) { console.log(">>>>> STUFF HAPPENED in TreeCollapsed"); });The full code for myDiagram looks like this:
myDiagram = $(go.Diagram, "myDiagramDiv", { "undoManager.isEnabled": true, layout: $(go.TreeLayout), "ChangedSelection": onSelectionChanged }); function geoFunc(geoname) { var geo = icons[geoname]; if (geo === undefined) geo = icons["heart"]; // use this for an unknown icon name if (typeof geo === "string") { geo = icons[geoname] = go.Geometry.parse(geo, true); // fill each geometry } return geo; } myDiagram.nodeTemplate = $(go.Node, "Auto", {isTreeExpanded:false}, {doubleClick: function(e, node) {node.expandTree(1);}}, $(go.Shape, "Rectangle", { strokeWidth: 2, stroke: colors["gray"], }, new go.Binding("fill", "color")), $(go.TextBlock, {stroke:"black",font:"12pt sans-serif",margin:3,wrap: go.TextBlock.WrapDesiredSize},new go.Binding("text", "geo")) ); // Define a Link template that routes orthogonally, with no arrowhead myDiagram.linkTemplate = $(go.Link, { routing: go.Link.Orthogonal, corner: 5, toShortLength: -2, fromShortLength: -2 }, $(go.Shape, { strokeWidth: 2, stroke: colors["gray"] })); // the link shape myDiagram.addDiagramListener("TreeExpanded", function(e) { console.log(">>>>> STUFF HAPPENED in TreeExpanded"); }); myDiagram.addDiagramListener("TreeCollapsed", function(e) { console.log(">>>>> STUFF HAPPENED in TreeCollapsed"); }); // Create the model data that will be represented by Nodes and Links myDiagram.model = new go.GraphLinksModel( [How do I detect when a node tree is expanded or collapsed, then call a function?
Posts: 3
Participants: 2