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

How to access node data from context menu inside node template?

$
0
0

@chathuraa wrote:

Hi,

I have the following code. How do I access node data?

const contextMenuGenerator = (nodedata) => {
  switch (nodedata.type) {
    case value:
      break;

    default:
      break;
  }

  return map(menuItems,()=>{return ...})
};

const nodeTemplate = $(
  go.Node,
  'Auto',
  {
    // handle dragging a Node onto a Node to (maybe) change the reporting relationship
    mouseDragEnter: onNodeDragEnter,
    mouseDragLeave: onNodeDragLeave,
    mouseDrop: onNodeDrop,
  },
  $(
    go.Shape,
    'RoundedRectangle',
    nodeStyleDefault,
    new go.Binding('fill', 'type', changeNodeFillStyle),
    new go.Binding('stroke', 'type', changeNodeStrokeStyle),
  ),
  $(
    go.TextBlock,
    'Default Text',
    nodeTextBoxStyle,
    new go.Binding('text', 'desc').makeTwoWay(),
  ),
  {
    // define a context menu for each node
    contextMenu: $(
      go.Adornment,
      'Vertical', // that has one button
      contextMenuGenerator(nodeData),
      // more ContextMenuButtons would go here
    ), // end Adornment
  },
  $('TreeExpanderButton', nodeTreeExpanderButtonConfig),
);

Thanks,
Chat

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles