-
Notifications
You must be signed in to change notification settings - Fork 6
/
App.tsx
72 lines (63 loc) · 2.27 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { useState } from 'react';
import { useEvent } from './utils';
import DataGrid, { Column, Editing, Popup, Form } from 'devextreme-react/data-grid';
import { Item } from 'devextreme-react/form';
import { cellRender, FileUploaderEditor } from './FileUploaderEditor';
import { employees } from './data';
import { ColumnEditCellTemplateData, EditCanceledEvent, SavedEvent } from 'devextreme/ui/data_grid';
function App() {
const [retryButtonVisible, setRetryButtonVisible] = useState(false);
const onEditCanceled = useEvent((e: EditCanceledEvent) => {
if (retryButtonVisible)
setRetryButtonVisible(false);
})
const onSaved = useEvent((e: SavedEvent) => {
if (retryButtonVisible)
setRetryButtonVisible(false);
})
const editCellRender = useEvent((cellInfo: ColumnEditCellTemplateData) => <FileUploaderEditor cellInfo={cellInfo} retryButtonVisible={retryButtonVisible} setRetryButtonVisible={setRetryButtonVisible} />)
return (
<DataGrid id="gridContainer"
dataSource={employees}
keyExpr={"ID"}
showBorders={true}
onEditCanceled={onEditCanceled}
onSaved={onSaved}
>
<Editing
mode="popup"
allowUpdating={true}>
<Popup title="Employee Info" showTitle={true} width={700} />
<Form>
<Item itemType="group" colCount={2} colSpan={2}>
<Item dataField="Prefix" />
<Item dataField="FirstName" />
<Item dataField="LastName" />
<Item dataField="Position" />
<Item dataField="BirthDate" />
<Item dataField="HireDate" />
</Item>
<Item itemType="group" caption="Photo" colCount={2} colSpan={2}>
<Item dataField="Picture" colSpan={2} />
</Item>
</Form>
</Editing>
<Column dataField="Picture"
width={70}
allowSorting={false}
cellRender={cellRender}
editCellRender={editCellRender}
/>
<Column dataField="Prefix"
width={70}
caption="Title"
/>
<Column dataField="FirstName" />
<Column dataField="LastName" />
<Column dataField="Position" />
<Column dataField="BirthDate" dataType="date" />
<Column dataField="HireDate" dataType="date" />
</DataGrid>
);
}
export default App;