Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

How can I change expand/collapse with Double tree?

$
0
0

@alice wrote:

Hello, I have a question.
How can I change expand/collapse with Double tree?

I would like expand / collapse to work when the 'A' or 'B' button is pressed.
In the example below, only the icon is changed.

$("Button",
    $(go.Shape,
      {
        name: "ButtonIcon",
        figure: "MinusLine",
        desiredSize: new go.Size(6, 6)
      },
      new go.Binding("figure", "isCollapsedRight",  // data.isCollapsedRight remembers whether "collapsed"
                     function(collapsed) { return collapsed ? "PlusLine" : "MinusLine"; })),
    {
      click: function(e, obj) {
        e.diagram.startTransaction();
        var node = obj.part;
        var collapsed = !node.data.isCollapsedRight;  // toggle collapse state
        // remember collapse state on root data, with support for bindings and undo
        e.diagram.model.setDataProperty(node.data, "isCollapsedRight", collapsed);
        // collapse/expand immediate children and toggle their visibility
        node.findLinksOutOf().each(function(n) {
            if (n.data.dir === "right") {  // just nodes on the right side of tree
                n.visible = !collapsed;
                n.isTreeExpanded = !collapsed;
            }
        });
        e.diagram.commitTransaction("toggled visibility of consequences");
      }
    })

How can I change expand/collapse with Double tree?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles