|
@Component({
selector: 'app-container',
template: `<ejs-grid #grid [dataSource]='data' id="gridcomp"
allowPaging='true' [allowExcelExport]='true' [allowPdfExport]='true' height='220px' [allowSorting]='true'
(contextMenuOpen)='contextMenuOpen($event)' [contextMenuItems]="contextMenuItems" [editSettings]='editing' [allowGrouping]='true'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign="Right" isPrimaryKey='true'></e-column>
. . .
</e-columns>
</ejs-grid>`
})
export class AppComponent implements OnInit {
. . .
public contextMenuItems: any[] = [{ text: 'Call Mobile: ', target: '.e-content', id: 'callMobile', url: 'tel:' }];
contextMenuOpen(e: any) {
const rowInfo: any = this.grid.getRowInfo(e.event.target);
const mobileNr: string = rowInfo.rowData[OrderID];
// dynamically changing the “text” and “url” properties of ContextMenu items.
this.grid.contextMenuModule.contextMenu.items.filter((item) => item.id === 'callMobile')[0].text = 'Call Mobile: ' + mobileNr;
this.grid.contextMenuModule.contextMenu.items.filter((item) => item.id === 'callMobile')[0].url = 'tel: ' + mobileNr;
}
} |