primevue-mirror/doc/tree/selection/MultipleDoc.vue

93 lines
3.2 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>
More than one node is selectable by setting <i>selectionMode</i> to <i>multiple</i>. By default in multiple selection mode, metaKey press (e.g. <i></i>) is necessary to add to existing selections however this can be configured with
disabling the <i>metaKeySelection</i> property. Note that in touch enabled devices, Tree always ignores metaKey.
</p>
<p>In multiple selection mode, value binding should be a key-value pair where key is the node key and value is a boolean to indicate selection.</p>
</DocSectionText>
<div class="card flex flex-column align-items-center justify-content-center">
<div class="flex align-items-center mb-4 gap-2">
<InputSwitch v-model="checked" inputId="input-metakey" />
<label for="input-metakey">MetaKey</label>
</div>
<Tree v-model:selectionKeys="selectedKey" :value="nodes" selectionMode="multiple" class="w-full md:w-30rem" :metaKeySelection="checked"></Tree>
</div>
<DocSectionCode :code="code" v-bind="$attrs" :service="['NodeService']" />
</template>
<script>
import { NodeService } from '@/service/NodeService';
export default {
data() {
return {
checked: false,
nodes: null,
selectedKey: null,
code: {
2023-09-22 12:54:14 +00:00
basic: `
<Tree v-model:selectionKeys="selectedKey" :value="nodes" class="w-full md:w-30rem"
2023-10-15 09:38:39 +00:00
selectionMode="multiple" :metaKeySelection="checked"></Tree>
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card flex flex-column align-items-center justify-content-center">
<div class="flex align-items-center mb-4 gap-2">
<InputSwitch v-model="checked" inputId="input-metakey" />
<label for="input-metakey">MetaKey</label>
</div>
<Tree v-model:selectionKeys="selectedKey" :value="nodes" selectionMode="multiple" class="w-full md:w-30rem" :metaKeySelection="checked"></Tree>
</div>
</template>
<script>
import { NodeService } from '@/service/NodeService';
export default {
data() {
return {
checked: false,
nodes: null,
selectedKey: null
};
},
mounted() {
NodeService.getTreeNodes().then((data) => (this.nodes = data));
}
}
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card flex flex-column align-items-center justify-content-center">
<div class="flex align-items-center mb-4 gap-2">
<InputSwitch v-model="checked" inputId="input-metakey" />
<label for="input-metakey">MetaKey</label>
</div>
<Tree v-model:selectionKeys="selectedKey" :value="nodes" selectionMode="multiple" class="w-full md:w-30rem" :metaKeySelection="checked"></Tree>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from '@/service/NodeService';
const nodes = ref(null);
const selectedKey = ref(null);
const checked = ref(false);
onMounted(() => {
NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
},
mounted() {
NodeService.getTreeNodes().then((data) => (this.nodes = data));
}
};
</script>