1

Need help in implementing context menu (right click) in angular2-tree-component. Please help in this.I have got the tree working fine. I dont know how to get the IActionMapping functions working.

1
  • have you got any solution ? Commented May 9, 2017 at 12:04

1 Answer 1

2

What I did was to programmatically trigger the context menu on right click.

  1. Add a hook for right click by specifying the action mapping in the tree option in your controller:

options: ITreeOptions = {
    actionMapping: {
        mouse: {
            contextMenu: (model: any, node: any, event: any) => {
                this.onContextMenu(event, node.data.name);
                console.log('in context menu...');
            }
        }
    },
};

  1. Specify this as your tree option in your tree-root:

<tree-root #tree [nodes]="nodes" [options]="options"></tree-root>

  1. trigger the context menu programmatically in the onContextMenu method- I used ngx-contextmenu
Sign up to request clarification or add additional context in comments.

2 Comments

How and where you have defined onContextMenu?
@FurqanSafdar have a look at npmjs.com/package/ngx-contextmenu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.