@Component({
template: `<ejs-grid #grid [dataSource]='data' [allowGrouping]='true' (contextMenuClick)='contextMenuClick($event)' [allowPaging]='true'
[toolbar]='toolbar' (toolbarClick)='toolbarClick($event)' [contextMenuItems]="contextMenuItems">
. . . . .
</ejs-grid>`,
providers: [ToolbarService, PageService, ExcelExportService, PdfExportService]
})
export class AppComponent implements OnInit {
ngOnInit(): void {
this.contextMenuItems = [{text: 'Copy with headers', target: '.e-content', id: 'copywithheader'},
{
text: 'Copy without headers',
items: [
{
text: 'Copy',
items:[
{
text: 'Copy with headers',
id: 'copywithheader1'
},
]
}
]
}];
}
contextMenuClick(args: any): void {
if (args.item.id === 'copywithheader') {
this.grid.copy(true);
alert('Copy with headers');
}
if (args.item.id === 'copywithheader1') {
alert('Deeper');
}
}
|
// set isUniqueId argument as true, if you want to insert items based on id
this.grid.contextMenuModule.contextMenu.insertAfter(
[{ text: 'test', id: 'test' }], 'copywithheader1', true);
// If you want to insert items based on text
this.grid.contextMenuModule.contextMenu.insertAfter(
[{ text: 'test', id: 'test' }], 'Copy') |