|
[app.component.html]
<div class="control-section">
<ejs-grid #grid [dataSource]='data' [editSettings]='editSettings' [contextMenuItems]="contextMenuItems" (commandClick)="commandClick($event)">
<e-columns>
. . . .
<e-column field='ShipCountry' headerText='Ship Country' width='150' editType='dropdownedit' [edit]='editparams'></e-column>
<e-column headerText='Manage Records' width='160' [commands]='commands'></e-column>
</e-columns>
</ejs-grid>
</div>
[app.component.ts]
public ngOnInit(): void {
. . . .
this.commands = [
{ buttonOption: { iconCss: 'glyphicon glyphicon-option-vertical', cssClass: 'e-flat' } },
];
this.contextMenuItems = ['AutoFit', 'AutoFitAll', 'SortAscending', 'SortDescending',
'Copy', 'Edit', 'Delete', 'Save', 'Cancel',
'PdfExport', 'ExcelExport', 'CsvExport', 'FirstPage', 'PrevPage',
'LastPage', 'NextPage'];
}
public commandClick(args:any){
(<any>this.grid.contextMenuModule).element.ej2_instances[0].openMenu(null, null, (<any>event).pageY, (<any>event).pageX, event);
}
|
|
[index.htmll]
<html lang="en">
<head>
<meta charset="utf-8">
<title>Window</title>
<link rel='nofollow' href="../../styles/OpenNew.css" rel="stylesheet">
<link rel='nofollow' href="//cdn.syncfusion.com/ej2/material.css" rel="stylesheet" />
<link rel="stylesheet" rel='nofollow' href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" rel='nofollow' href="favicon.ico">
</head>
</html>
|
|
[app.component.html]
<ejs-grid #grid [dataSource]='data' [contextMenuItems]="contextMenuItems" (commandClick)="commandClick($event)">
. . . .
</ejs-grid>
[app.component.ts]
import { Component, OnInit,ViewChild } from '@angular/core';
import { CommandColumnService, CommandModel,GridComponent, ContextMenuService,ContextMenuItem } from '@syncfusion/ej2-angular-grids';
export class AppComponent {
@ViewChild("grid")
public grid:GridComponent // Here, bind the Grid component instance in Angular application(this), now you can use “this.grid” in commandClick event
} |