@@ -2,32 +2,35 @@ import React, { useCallback } from 'react';
2
2
import './App.css' ;
3
3
import 'devextreme/dist/css/dx.material.blue.light.compact.css' ;
4
4
import DataGrid , {
5
- Column , Paging , Pager , Editing ,
5
+ Column , Paging , Pager , Editing , type DataGridTypes ,
6
6
} from 'devextreme-react/data-grid' ;
7
7
import { employees } from './data' ;
8
8
9
9
const allowedPageSizes = [ 5 , 10 , 20 ] ;
10
10
11
11
function App ( ) : JSX . Element {
12
- const onContextMenuPreparing = useCallback ( ( e : any ) : void => {
13
- if ( e . row . rowType === 'data' ) {
12
+ const onContextMenuPreparing = useCallback ( ( e : DataGridTypes . ContextMenuPreparingEvent ) : void => {
13
+ if ( e . row ?. rowType === 'data' ) {
14
+ const rowIndex = e . row . rowIndex ;
15
+ if ( e . rowIndex === undefined ) return ;
14
16
e . items = [
15
17
{
16
18
text : 'edit' ,
17
19
onItemClick ( ) : void {
18
- e . component . editRow ( e . row . rowIndex ) ;
20
+ e . component . editRow ( rowIndex ) ;
19
21
} ,
20
22
} ,
21
23
{
22
24
text : 'insert' ,
23
- onItemClick ( ) : void {
24
- e . component . addRow ( ) ;
25
+ // eslint-disable-next-line @typescript-eslint/space-before-function-paren
26
+ onItemClick : async ( ) : Promise < void > => {
27
+ await e . component . addRow ( ) ;
25
28
} ,
26
29
} ,
27
30
{
28
31
text : 'delete' ,
29
32
onItemClick ( ) : void {
30
- e . component . deleteRow ( e . row . rowIndex ) ;
33
+ e . component . deleteRow ( rowIndex ) ;
31
34
} ,
32
35
} ,
33
36
] ;
0 commit comments