-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
65 lines (58 loc) · 2.06 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { useCallback } from 'react';
import 'devextreme/dist/css/dx.common.css';
import 'devextreme/dist/css/dx.material.blue.light.compact.css';
import './App.css';
import {
DataGrid,
Column,
Selection,
FilterRow,
GroupPanel,
Pager,
StateStoring
} from 'devextreme-react/data-grid';
import { orders } from './data';
const storageKey = "datagrid-state";
const allowedPageSizes = [5, 10, 20];
function App() {
const loadState = useCallback(() => {
return JSON.parse(localStorage.getItem(storageKey));
}, []);
const saveState = useCallback((state) => {
if (state) {
for (let i = 0; i < state.columns.length; i++) {
state.columns[i].filterValue = null;
}
}
localStorage.setItem(storageKey, JSON.stringify(state));
}, []);
return (
<div className="App">
<DataGrid
dataSource={orders}
keyExpr="ID"
allowColumnResizing={true}
allowColumnReordering={true}
showBorders={true}>
<Column dataField="OrderNumber" caption="Invoice Number" width={130} />
<Column dataField="OrderDate" sortOrder="desc" dataType="date" />
<Column dataField="SaleAmount" alignment="right" format="currency" />
<Column dataField="Employee" />
<Column dataField="CustomerStoreCity" caption="City" />
<Column dataField="CustomerStoreState" caption="State" groupIndex={0} />
<Selection mode="single" />
<FilterRow visible={true} />
<GroupPanel visible={true} />
<Pager showPageSizeSelector={true} allowedPageSizes={allowedPageSizes} />
<StateStoring
enabled={true}
type="custom"
storageKey={storageKey}
customLoad={loadState}
customSave={saveState}
/>
</DataGrid>
</div>
);
}
export default App;