-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHomeContent.vue
More file actions
82 lines (77 loc) · 1.75 KB
/
Copy pathHomeContent.vue
File metadata and controls
82 lines (77 loc) · 1.75 KB
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
73
74
75
76
77
78
79
80
81
82
<template>
<DxDataGrid
:data-source="orders"
key-expr="ID"
:allow-column-resizing="true"
:allow-column-reordering="true"
:show-borders="true"
>
<DxColumn
:width="130"
data-field="OrderNumber"
caption="Invoice Number"
/>
<DxColumn
data-field="OrderDate"
sort-order="desc"
data-type="date"
/>
<DxColumn
data-field="SaleAmount"
alignment="right"
format="currency"
/>
<DxColumn data-field="Employee"/>
<DxColumn
data-field="CustomerStoreCity"
caption="City"
/>
<DxColumn
:group-index="0"
data-field="CustomerStoreState"
caption="State"
/>
<DxSelection mode="single"/>
<DxFilterRow :visible="true"/>
<DxGroupPanel :visible="true"/>
<DxPager
:show-page-size-selector="true"
:allowed-page-sizes="[5, 10, 20]"
/>
<DxStateStoring
:enabled="true"
type="custom"
:storage-key="storageKey"
:custom-load="loadState"
:custom-save="saveState"
/>
</DxDataGrid>
</template>
<script setup lang="ts">
import {
DxDataGrid,
DxColumn,
DxSelection,
DxFilterRow,
DxGroupPanel,
DxPager,
DxStateStoring,
} from 'devextreme-vue/data-grid';
import { orders } from '../data';
defineOptions({ name: 'HomeContent' });
const storageKey = 'datagrid-state';
function loadState() {
return JSON.parse(localStorage.getItem(storageKey) as string) as object | null;
}
function saveState(state: object | null): void {
if (state) {
const columns = (state as { columns?: { filterValue?: unknown }[] }).columns;
if (columns) {
for (const col of columns) {
col.filterValue = null;
}
}
}
localStorage.setItem(storageKey, JSON.stringify(state));
}
</script>