-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStateDropDownBoxComponent.vue
More file actions
59 lines (53 loc) · 1.7 KB
/
StateDropDownBoxComponent.vue
File metadata and controls
59 lines (53 loc) · 1.7 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
<template>
<DxDropDownBox
:data-source="dataSource"
v-model:value="currentValue"
display-expr="Name"
value-expr="ID"
content-template="contentTemplate"
>
<template #contentTemplate="{ data }">
<div>
<DxDataGrid
:data-source="dataSource"
key-expr="ID"
:selected-row-keys="currentValue"
:hover-state-enabled="true"
:height="250"
@initialized="onInitialized"
>
<DxColumn data-field="ID"/>
<DxColumn data-field="Name"/>
<DxSelection mode="multiple"/>
</DxDataGrid>
<DropDownSaveBtnComponent
:data-grid="dataGrid"
:cell-info="cellInfo"
:drop-down-box="data.component"
/>
</div>
</template>
</DxDropDownBox>
</template>
<script setup lang="ts">
import { ref, watch, type Ref } from 'vue';
import { DxDataGrid, DxSelection, DxColumn, type DxDataGridTypes } from 'devextreme-vue/data-grid';
import DxDropDownBox from 'devextreme-vue/drop-down-box';
import DropDownSaveBtnComponent from './DropDownSaveBtnComponent.vue';
import type { Employee, State } from '../data';
interface Props {
value: number[] | undefined;
onValueChanged: (value: number[]) => void;
dataSource: State[];
cellInfo: DxDataGridTypes.ColumnEditCellTemplateData<Employee, number>;
}
const props = defineProps<Props>();
const currentValue: Ref<number[]> = ref([...(props.value || [])]);
const dataGrid = ref();
const onInitialized = (e: DxDataGridTypes.InitializedEvent): void => {
dataGrid.value = e.component;
};
watch(() => props.value, (newValue: number[] | undefined) => {
currentValue.value = [...(newValue || [])];
}, { deep: true });
</script>