Skip to content

Commit 9db1128

Browse files
Update Angular event type
1 parent fc22336 commit 9db1128

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

Angular/src/app/app.component.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component } from "@angular/core";
22
import { Service } from "./app.service";
3+
import { DxDataGridTypes } from 'devextreme-angular/ui/data-grid';
34

45
@Component({
56
selector: 'app-root',
@@ -11,29 +12,30 @@ export class AppComponent {
1112
employees: any;
1213
readonly allowedPageSizes = [5, 10, 20];
1314

14-
onContextMenuPreparing(e: any){
15-
if (e.row.rowType === "data") {
16-
e.items =
17-
[
18-
{
19-
text: "edit",
20-
onItemClick: function () {
21-
e.component.editRow(e.row.rowIndex);
22-
}
15+
onContextMenuPreparing(e: DxDataGridTypes.ContextMenuPreparingEvent){
16+
if (e.row?.rowType === 'data') {
17+
const rowIndex = e.row.rowIndex;
18+
if (e.rowIndex === undefined) return;
19+
e.items = [
20+
{
21+
text: 'edit',
22+
onItemClick(): void {
23+
e.component.editRow(rowIndex);
2324
},
24-
{
25-
text: "insert",
26-
onItemClick: function () {
27-
e.component.addRow();
28-
}
25+
},
26+
{
27+
text: 'insert',
28+
onItemClick: async(): Promise<void> => {
29+
await e.component.addRow();
2930
},
30-
{
31-
text: "delete",
32-
onItemClick: function () {
33-
e.component.deleteRow(e.row.rowIndex);
34-
}
35-
}
36-
];
31+
},
32+
{
33+
text: 'delete',
34+
onItemClick(): void {
35+
e.component.deleteRow(rowIndex);
36+
},
37+
},
38+
];
3739
}
3840
}
3941

0 commit comments

Comments
 (0)