Dynamic ContextMenu

As far as I know, there is no build in way to open the ContextMenu from server side.
Look at my post where I “convert” a client left click to a right click that opens the GridContextMenu. There I also collect data before the ContextMenu is opened.

You may want to use this on a Button Click Listener, so you can trigger a context menu open from the server side that requires once roundtrip:

// not tested code
button.addClickListener(clickEvent -> {
       button.getElement().executeJs("""
              $0.dispatchEvent(new MouseEvent('contextmenu', { 'view': window, 'bubbles': true, 'cancelable': true }))
       """, button ) /* the client element will be used as $0 */
})