-
Notifications
You must be signed in to change notification settings - Fork 776
/
MatrixRow.vue
49 lines (46 loc) · 1.13 KB
/
MatrixRow.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
<template>
<tr
:data-sv-drop-target-matrix-row="row.row && row.row.id"
@pointerdown="question.onPointerDown($event, row.row)"
:class="row.className"
v-if="row.visible"
ref="root"
>
<survey-matrixdropdown-cell
:cell="cell"
:question="question"
v-for="(cell, cellIndex) in row.cells"
:key="row.id + '_' + cellIndex"
/>
</tr>
</template>
<script lang="ts" setup>
import type {
QuestionMatrixDropdownRenderedRow,
QuestionMatrixDropdownModel,
} from "survey-core";
import { useBase } from "./base";
import { watch, onMounted, onUnmounted, ref } from "vue";
const props = defineProps<{
question: QuestionMatrixDropdownModel;
row: QuestionMatrixDropdownRenderedRow;
}>();
const root = ref<HTMLElement>();
useBase(() => props.row);
const stopWatch = watch(
() => props.row,
(newValue, oldValue) => {
if (oldValue) {
oldValue.setRootElement(undefined as any);
}
newValue.setRootElement(root.value as any);
}
);
onMounted(() => {
props.row.setRootElement(root.value as any);
});
onUnmounted(() => {
props.row.setRootElement(undefined as any);
stopWatch();
});
</script>