[GoJS] GoJS Change context menu items
gojs
Web icon
Forge component by Sónia Ferreira
Application Type
Traditional Web

I have successfully implemented GoJs diagram into my web app. There is a context menu when right clicking on a node that has "Option 1, Option 2, Option 3".

I would like to use the menu but am not able to identify where to change those labels. I have reviewed all JS in the GoJS module but cannot find any menu labels that are set to Option x. Also, I tested adding a parm to the GoJs module with "test item", as there is a parm to the main function for contextMenu but that did not help.

Does anyone know where to change these labels? or have an example app that has changed these and possibly, doing subsequent logic after selecting one of the menu options?


Thank you,

David

Solution

Hi David,


You can use JavaScript to add listeners to the options and point them to a client action. On the client action, I would trigger an event, to be able to control how to handle them on the consumer side.


Kind Regards,
João

Hi David,


The option menus are "hardcoded" in the GoJS module itself, in the GoJS screen, in the false branch, like in the image below:


You can hardcode your values, or adapt the asset so the consumer, can define these options.


Kind Regards,
João

I see them now, thank you for the guidance.

One other item, when a menu item is clicked, I do get the values returned but am looking for a way to trigger a client action so user can take some action. Any idea on how to do that or an example?

Solution

Hi David,


You can use JavaScript to add listeners to the options and point them to a client action. On the client action, I would trigger an event, to be able to control how to handle them on the consumer side.


Kind Regards,
João

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.