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

120 lines
4.0 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: `
2023-11-28 09:23:46 +00:00
<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-11-28 09:23:46 +00:00
`,
data: `
{
key: '0',
label: 'Documents',
data: 'Documents Folder',
icon: 'pi pi-fw pi-inbox',
children: [
{
key: '0-0',
label: 'Work',
data: 'Work Folder',
icon: 'pi pi-fw pi-cog',
children: [
{ key: '0-0-0', label: 'Expenses.doc', icon: 'pi pi-fw pi-file', data: 'Expenses Document' },
{ key: '0-0-1', label: 'Resume.doc', icon: 'pi pi-fw pi-file', data: 'Resume Document' }
]
},
{
key: '0-1',
label: 'Home',
data: 'Home Folder',
icon: 'pi pi-fw pi-home',
children: [{ key: '0-1-0', label: 'Invoices.txt', icon: 'pi pi-fw pi-file', data: 'Invoices for this month' }]
}
]
},
...`
2023-02-28 08:29:30 +00:00
}
};
},
mounted() {
NodeService.getTreeNodes().then((data) => (this.nodes = data));
}
};
</script>