Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143808 | Apr 5,2019 12:01 PM UTC | Apr 9,2019 10:59 AM UTC | Angular - EJ 2 | 3 |
![]() |
Tags: ContextMenu |
@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') |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.