-
Notifications
You must be signed in to change notification settings - Fork 2
/
Home.vue
98 lines (94 loc) · 2.28 KB
/
Home.vue
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<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>
import {
DxDataGrid,
DxColumn,
DxSelection,
DxFilterRow,
DxGroupPanel,
DxPager,
DxStateStoring
} from 'devextreme-vue/data-grid';
import { orders } from '../data';
export default {
name: 'Home',
components: {
DxDataGrid,
DxColumn,
DxSelection,
DxFilterRow,
DxGroupPanel,
DxPager,
DxStateStoring
},
data() {
return {
orders,
storageKey: "datagrid-state"
}
},
methods: {
loadState() {
return JSON.parse(localStorage.getItem(this.storageKey));
},
saveState(state) {
if (state) {
for (let i = 0; i < state.columns.length; i++) {
state.columns[i].filterValue = null;
}
}
localStorage.setItem(this.storageKey, JSON.stringify(state));
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>