Add tree expander button on basis of a condition

Hi,
Say i have a json:
[
{
“id”: “abc”,
“hasSubprocess”: “ui-xd”,
“parent”: null
},
{
“id”: “bcd”,
“hasSubprocess”: null,
“parent”: “abc”
},
{
“id”: “cde”,
“hasSubprocess”: “ui-id”,
“parent”: “bcd”
}
]

i) On the basis of hasSubprocess value, i want to display a treeExpanderButton(i.e. if it’s not null then it shows a treeExpanderButton).

ii) If there’s a treeExpanderButton, then on click of that button(on demand) i have to fetch the sub-process tree and display it there.

How can i achieve the mentioned two cases?(Also, the above tree with 3 nodes is present there already.

I think you do not want a “TreeExpanderButton”, because it has specific behavior and you want something different. Use a “Button” instead. GoJS Buttons -- Northwoods Software

Have that “Button”'s visible property data bound to the “hasSubprocess” property:

    $("Button",
       new go.Binding("visible", "hasSubprocess", function(h) { return !!h; }),
       { click: function(e, button) {
           ... request data for button.part.data.id ...
          }
       },
       . . .),
    . . .

Hi Walter,

This solves the first problem. But , is it possible that click of that button, i make a REST call , fetch data and then show that data as child nodes connected to the node whose button is clicked. With all the other nodes intact.

The button click will give us another json something like: (will be shown as expanded tree. Can further have subprocess).
{
“Subprocess”: “ui-xd”,
[
{
“id”: “smi”,
“hasSubprocess”: “op-xd”,
“parent”: “abc”
},
{
“id”: “poo”,
“hasSubprocess”: null,
“parent”: “smi”
}
]

Have that button click handler make your REST API call. When you successfully receive the new data, start a transaction, add the node data to the model as children of the intended parent, and commit the transaction.