Org chart editor disable the node

Hi Walter

How to disable the node and grey out the color
i am doing below but it is not greying out.

myDiagram.nodes.each(function(n) {
var shape = n.findObject(“SHAPE”);
if (shape) shape.fill = $(go.Brush, “Linear”, { 0: ‘#A9A9A9’, 1: go.Brush.lightenBy(’#A9A9A9’, 0.05), start: go.Spot.Left, end: go.Spot.Right });
}

Normally “disabling a node” means setting its permission properties, such as Part.selectable, Part.movable, Part.deletable and so on. Read GoJS User Permissions -- Northwoods Software for more details.

You are asking about changing the appearance of a node when it is in a certain state. What you suggest should work to change the Shape.fill of all of the Nodes that have a Shape named “SHAPE” in them.

But there are alternatives. You could, for example, just set each Node’s GraphObject.opacity to 0.5 or so, to make the whole Node appear translucent, and thus lighter and grayer.

Or you could change your node template(s) so that there was a large Shape covering the whole area of the node. Its Shape.fill and Shape.stroke would normally be null. When you wanted to make the node appear “disabled”, you would change that Shape.fill to be a translucent black, causing the whole node to be grayed out.

For example, this code has a rectangle in front of the body of a simple node. Its fill is bound to a disabled property on the data:

    myDiagram.nodeTemplate =
      $(go.Node, "Table",
        $(go.Panel, "Auto",  // this had been the Node in the original template
          $(go.Shape,
            { strokeWidth: 0 },
            new go.Binding("fill", "color")),
          $(go.TextBlock,
            { margin: 8 },
            new go.Binding("text", "key"))
        ),
        $(go.Shape,
          { stretch: go.GraphObject.Fill, fill: null, strokeWidth: 0 },
          new go.Binding("fill", "disabled", function(h) { return h ? "#00000030" : null; }))
      );

Of course this works for rectangular nodes – you might need to customize the geometry of the Shape for other node templates.

Hi Walter
I want to disable the node based on node data. is there any sample piece of code based on node data can i disable the node.

and also what is wrong with this below code not getting color changed

n.findObject(“SHAPE”).fill = $(go.Brush, “Linear”, { 0: ‘#A9A9A9’, 1: go.Brush.lightenBy(’#A9A9A9’, 0.05), start: go.Spot.Left, end: go.Spot.Right });

My example template, above, depends on the data.disabled property. Adapt for your own needs.

There’s nothing wrong with that code. But you’ll want to make all changes while conducting a transaction – in other words around your loop iterating over a collection of nodes.