are not clear where this code is supposed to go
You can init context menu in the same code where the related tree is initialized. It will be hidden by default and will appear only on context click
Does the context menu automatically show
If you have used .attachTo api, menu will be shown automatically.
menu may have a different list
You can use menu.clearAll and menu.parse to reload list of options ( or use hideItem api to hide unnecessary items only )