Hi Denis,
We have created a grid sample in Angular 2 which can be downloaded from the below location.
In the above sample, we have enabled the context menu for the grid which is working fine at our end. So please try the sample and if you still face any issues, please reproduce the issue in the above provided sample and share.
Regards,
Ragavee U S.
Hello. Thank you. I tried to implement solution from your example. Context menu still don't appear, shows error in debugger console: "Invalid input for property :contextMenuSettings - customContextMenuItems : Expected type - array". As early it was standard Chrome context menu, now it don't appears. It shows data in grid, and that's all. If I remove contextMenuSettings.customContextMenuItems from template, it don't show error, but still don't show context menu. What's wrong?! Here is my code:
import {Component, Input,Output, EventEmitter, OnInit, OnDestroy, ElementRef, OnChanges, SimpleChange} from 'angular2/core';
import {ConsoleService} from '../services/console.service';
import {OID, OsbmCommand} from '../types/model'
import {iDxItem, DxItemByCommand} from './dx.model'
import {EJ_GRID_COMPONENTS} from "ej/grid.component";
import {CORE_DIRECTIVES} from "angular2/common";
@Component({
selector: 'dx-grid',
inputs: ['pageSize'],
template: `
<ej-grid [allowPaging]="true" [allowSorting]="true" [dataSource]="gridData" editSettings.allowEditing="true" editSettings.allowAdding="true"
contextMenuSettings.enableContextMenu="true"
contextMenuSettings.customContextMenuItems="menuItems"
>
<e-columns>
<e-column field = "OrderID" [isPrimaryKey]="true" headerText="Order ID" width="75" textAlign="right" ></e-column>
<e-column field="CustomerID" headerText="Customer ID" width="80"></e-column>
<e-column field="EmployeeID" headerText="Employee ID" width="75" textAlign="right"></e-column>
<e-column field="Freight" width="75" format="{0:C}" textAlign="right"></e-column>
<e-column field="OrderDate" headerText="Order Date" width="80" format="{0:MM/dd/yyyy}" textAlign="right"></e-column>
<e-column field="ShipCity" headerText="Ship City" width="110"></e-column>
</e-columns>
</ej-grid>
`,
directives: [EJ_GRID_COMPONENTS, CORE_DIRECTIVES]
})
export class DxGrid implements OnInit, OnDestroy {
public menuItems = ["Clear selection","Select all"];
public gridData = [{
OrderID: 10280,
CustomerID: "BERGS",
EmployeeID: 2,
OrderDate: new Date(840006e6),
RequiredDate: new Date(8424252e5),
ShippedDate: new Date(8425116e5),
ShipVia: 1,
Freight: 8.98,
ShipName: "Berglunds snabbköp",
ShipAddress: "Berguvsvägen 8",
ShipCity: "Luleå",
ShipRegion: null,
ShipPostalCode: "S-958 22",
ShipCountry: "Sweden",
CompanyName: "Berglunds snabbköp",
Address: "Berguvsvägen 8",
City: "Luleå",
Region: null,
PostalCode: "S-958 22",
Country: "Sweden"
}, {
OrderID: 10265,
CustomerID: "BLONP",
EmployeeID: 2,
OrderDate: new Date(838278e6),
RequiredDate: new Date(8406972e5),
ShippedDate: new Date(8398332e5),
ShipVia: 1,
Freight: 55.28,
ShipName: "Blondel père et fils",
ShipAddress: "24, place Kléber",
ShipCity: "Strasbourg",
ShipRegion: null,
ShipPostalCode: "67000",
ShipCountry: "France",
CompanyName: "Blondesddsl père et fils",
Address: "24, place Kléber",
City: "Strasbourg",
Region: null,
PostalCode: "67000",
Country: "France"
}, {
OrderID: 10663,
CustomerID: "BONAP",
EmployeeID: 2,
OrderDate: new Date(8738748e5),
RequiredDate: new Date(8750844e5),
ShippedDate: new Date(875862e6),
ShipVia: 2,
Freight: 113.15,
ShipName: "Bon app'",
ShipAddress: "12, rue des Bouchers",
ShipCity: "Marseille",
ShipRegion: null,
ShipPostalCode: "13008",
ShipCountry: "France",
CompanyName: "Bon app'",
Address: "12, rue des Bouchers",
City: "Marseille",
Region: null,
PostalCode: "13008",
Country: "France"
}];
constructor(private console: ConsoleService, elementRef: ElementRef) {
}
protected refresh() {
}
protected setData(data?: Array<any>) {
}
protected setColumns(cols?: Array<any>) {
}
ngOnInit() {
var _self = this;
}
ngOnDestroy() { }
}