import { Component } from '@angular/core'; @Component({ selector: 'contextmenu-demo', template: `

Context Menu Event Source

Note: angular2-data-table does not provide a context menu feature. This demonstrates how you would access the contextmenu event to display your own custom context menu.

Mouse position: (x: {{rawEvent?.x}}, y: {{rawEvent?.y}})

Row: {{contextmenuRow?.name}}

` }) export class ContextMenuDemoComponent { rows = []; columns = [ { prop: 'name' }, { name: 'Gender' }, { name: 'Company' } ]; rawEvent: MouseEvent; contextmenuRow: any; constructor() { this.fetch((data) => { this.rows = data; }); } onContextMenu(contextMenuEvent) { console.log(contextMenuEvent); this.rawEvent = contextMenuEvent.event; this.contextmenuRow = contextMenuEvent.row; contextMenuEvent.event.preventDefault(); contextMenuEvent.event.stopPropagation(); } fetch(cb) { const req = new XMLHttpRequest(); req.open('GET', `assets/data/company.json`); req.onload = () => { cb(JSON.parse(req.response)); }; req.send(); } }