Vue UI Components Documentation
The Vue Tree shows a hierarchical collection of items, with check boxes, drag-and-drop and load-on-demand. This guide adds the Vue Tree (jqxTree) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-vue3/vue_jqxtree.vue 
In a Vue 3 project (to start one, see Getting started with Vue), add the package:
npm install jqwidgets-scripts
import JqxTree from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxtree.vue';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.base.css';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.tailwind-blue-dark.css';
With <script setup>, an imported component is ready to use in the template. jqx.base.css is required; the second file is a theme, selected with the theme attribute.
The Default Functionality demo as a Single-File Component:
<template>
<div>
<JqxExpander :width="300" :height="370" :showArrow="false" :toggleMode="'none'">
<div>Folders</div>
<div style="overflow: hidden">
<JqxTree ref="myTree" :width="'100%'" :height="'100%'" :source="treeSource">
</JqxTree>
</div>
</JqxExpander>
</div>
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxTree from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxtree.vue';
import JqxExpander from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxexpander.vue';
const myTree = ref(null);
const treeSource = ref([
{
icon: 'https://www.jqwidgets.com/vue/images/mailIcon.png',
label: 'Mail',
expanded: true,
items: [
{ icon: 'https://www.jqwidgets.com/vue/images/calendarIcon.png', label: 'Calendar' },
{
icon: 'https://www.jqwidgets.com/vue/images/contactsIcon.png',
label: 'Contacts',
selected: true
}
]
},
{
icon: 'https://www.jqwidgets.com/vue/images/folder.png',
label: 'Inbox',
expanded: true,
items: [
{ icon: 'https://www.jqwidgets.com/vue/images/folder.png', label: 'Admin' },
{ icon: 'https://www.jqwidgets.com/vue/images/folder.png', label: 'Corporate' },
{ icon: 'https://www.jqwidgets.com/vue/images/folder.png', label: 'Finance' },
{ icon: 'https://www.jqwidgets.com/vue/images/folder.png', label: 'Other' }
]
},
{ icon: 'https://www.jqwidgets.com/vue/images/recycle.png', label: 'Deleted Items' },
{ icon: 'https://www.jqwidgets.com/vue/images/notesIcon.png', label: 'Notes' },
{ icon: 'https://www.jqwidgets.com/vue/images/settings.png', label: 'Settings', iconsize: 14 },
{ icon: 'https://www.jqwidgets.com/vue/images/favorites.png', label: 'Favorites' }
]);
onMounted(() => {
myTree.value.selectItem(null);
});
</script>
Options are attributes. Bind values from the script with :, for example :width="850".
Listen to an event with @ and its name. For example, select: This event is triggered when the user selects a tree item.
<script setup>
function onSelect(event) {
console.log(event.args);
}
</script>
<template>
<JqxTree @select="onSelect" />
</template>
Call methods through a template ref. For example, val: Sets or gets the selected item.
<script setup>
import { ref, onMounted } from 'vue';
const myTree = ref(null);
onMounted(() => {
const value = myTree.value.val();
console.log(value);
});
</script>
<template>
<JqxTree ref="myTree" />
</template>
Every component also has setOptions({ … }) and getOptions('name').