Add/remove button in ContextMenu

I created a Diagram with node and links and what I’m trying to do is to add and remove button in the contextmenu.
The structure is so simple and I create the menu buttons with this function:

makeButton = (btnText, action, visiblePredicate) => {
    return $(
      $(go.TextBlock, btnText),
      { click: action },
        ? new go.Binding("visible", "", function(o, e) {
            return o.diagram ? visiblePredicate(o, e) : false
        : {}

Code that I found in one of your example

The node data contains those information

let node = {
        key: dataNode.NodeId,
        NodeId: dataNode.NodeId,
        DimensionName: dataNode.DimensionName,
        Filter: dataNode.Filter,
        NodeLabel: dataNode.NodeLabel,
        ok: formatValue(dataNode.Ok, dataNode.OkPercentage),
        warning: formatValue(dataNode.Warning, dataNode.WarningPercentage),
        error: formatValue(dataNode.Error, dataNode.ErrorPercentage),

The visiblePredicate has this form:

(e, obj) => {
        return === "Root" ||
        !"A") //or B or C

I have three different button which work as a three different filter: A, B and C.
If you click on button A you retrieve some new nodes from server, every node has its buttons and what I would like that if you click on button A, the retrieved nodes have only button B and C, and if you click on B the retrieved new nodes have only button C.
How can I reach this solution?

I think you have the right idea – the visiblePredicate needs to look at the node data to decide whether the “ContextMenuButton” should be visible or not.

Or are you saying that the node data for nodes of type “B” or “C” do not have any such identifying information on them? If that’s the case I don’t know how to help you – you’ve got to make sure that you can tell programmatically what type of node it is.

Hi Walter,
thanks for your reply. In the node I have some information about the filter but for some reason I don’t know why it doesn’t work. I tried this solution:

      (e, obj) => {
      (e, obj) => {
        return (
 === "Root" ||

And pretty the same for type “B” and “C”. In every node I have a string “Filter” which contains the last filter that I used so I have think that the above solution would work, but it doesn’t.
Do you have any advice?

You’ll need to step through the code to see what your “Filter” is doing.