File tree Expand file tree Collapse file tree 1 file changed +23
-21
lines changed Expand file tree Collapse file tree 1 file changed +23
-21
lines changed Original file line number Diff line number Diff line change 1
1
import { Component } from "@angular/core" ;
2
2
import { Service } from "./app.service" ;
3
+ import { DxDataGridTypes } from 'devextreme-angular/ui/data-grid' ;
3
4
4
5
@Component ( {
5
6
selector : 'app-root' ,
@@ -11,29 +12,30 @@ export class AppComponent {
11
12
employees : any ;
12
13
readonly allowedPageSizes = [ 5 , 10 , 20 ] ;
13
14
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 ) ;
23
24
} ,
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 ( ) ;
29
30
} ,
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
+ ] ;
37
39
}
38
40
}
39
41
You can’t perform that action at this time.
0 commit comments