-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApp.js
50 lines (44 loc) · 1.31 KB
/
App.js
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
import React from "react";
import './App.css';
import 'devextreme/dist/css/dx.common.css';
import 'devextreme/dist/css/dx.light.css';
import DataGrid, { Editing, Column, Lookup } from "devextreme-react/data-grid";
import { customers, employees } from "./data";
function App(props) {
function onEditorPreparing(e) {
if (e.parentType === "dataRow" && e.dataField === "CustomerID") {
e.editorOptions.onValueChanged = function (ev) {
let selectedItem = ev.component.option("selectedItem");
e.setValue(selectedItem);
};
}
}
function setCellValue(rowData, value) {
rowData.CustomerID = value.CustomerID;
rowData.Address = value.Address;
rowData.Phone = value.Phone;
}
return (
<div>
<DataGrid
dataSource={employees}
onEditorPreparing={onEditorPreparing}>
<Editing
allowUpdating={true}
allowAdding={true} />
<Column
caption="Name"
dataField="CustomerID"
setCellValue={setCellValue}>
<Lookup
dataSource={customers}
valueExpr="CustomerID"
displayExpr="CustomerName" />
</Column>
<Column dataField="Address" />
<Column dataField="Phone" />
</DataGrid>
</div>
);
}
export default App;