Hiding context menu based on node data


Can we hide the context menu buttons based on node data. or

when you right click the event fire on the node based on node data the context menu displayed…

here i have 10 context menu options . when you click on disabled nodes only two context menu options i need to show

Is there any way we can show on the node as button icon the context menu instead of right click.


Have you seen the Adornment Buttons sample? In that sample, buttons are displayed upon selecting a node, and you’ll also notice the one of the buttons uses a Binding on the color of the node data. You could use a similar Binding to toggle visibility of buttons based on some node data properties.


can i call
node.contextMenu.removeAt(“context menu option name”) ?
or can you suggest
how to remove contextmenu options on node select or click

You shouldn’t need to remove ContextMenu buttons, you should just set their visibility based on your node data properties.

Presumably your ContextMenu would be defined something like this:

$(go.Adornment, "Vertical",
    $(go.TextBlock, "Button 1"),
      click: function(e, obj) { return true; }
    new go.Binding("visible", "someProperty")
    $(go.TextBlock, "Button 2"),
      click: function(e, obj) { return true; }
    new go.Binding("visible", "anotherProperty")

Hi Can i show the context menu based on “Button Click” on the node?

Right now in Chart diagram it is showing only when you right click

Sure, define an Adornment, then show it as part of your button’s click function. You may also need to hide it as part of the click functions within the Adornment itself.

We have the Hover Buttons sample which does this upon hover rather than clicking a button.

I did below code… not working please advise… no errors. but when i hover nothing is shwoing…

{ // show the Adornment when a mouseHover event occurs
mouseHover: function(e, obj) {
var node = obj.part;
nodeHoverAdornment.adornedObject = node;
node.addAdornment(“mouseHover”, nodeContextMenuAdornment);

var nodeContextMenuAdornment = $(
$(go.TextBlock, "View Command Info "),

You should let GoJS manage the context menu. Call CommandHandler | GoJS API, assuming there is a contextMenu on your node.

Yes walter I got that. Context menu should show when i click button or hover on the node. “Not the Right click”… how to show context menu when i click button?

Hi walter

Please ignore my comments above

I got it worked… by calling below