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 Answer
What I did was to programmatically trigger the context menu on right click.
- 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...');
}
}
},
};
- Specify this as your tree option in your tree-root:
<tree-root #tree [nodes]="nodes" [options]="options"></tree-root>
- trigger the context menu programmatically in the onContextMenu method- I used ngx-contextmenu
2 Comments
Furqan Safdar
How and where you have defined
onContextMenu?umasudhan
@FurqanSafdar have a look at npmjs.com/package/ngx-contextmenu