All Components

TreeView Overview

The TreeView displays hierarchical data in a traditional tree structure.

It supports user interaction through mouse or touch events and performs re-ordering operations by using the drag-and-drop functionality.

The TreeView wrapper for Vue is a client-side wrapper for the Kendo UI TreeView widget.

Installation

To initialize the TreeView, either:

Initializing from CDN

The following example demonstrates how to initialize the TreeView component by using the CDN services. To access all CDN references, open the sample in Plunker.

<div id="vueapp" class="vue-app">
    <kendo-treeview>
        <li data-expanded="true">
            <span class="k-icon k-i-folder"></span>
            My Web Site
            <ul>
                <li data-expanded="true">
                    <span class="k-icon k-i-folder"></span>images
                    <ul>
                        <li><span class="k-icon k-i-image"></span>logo.png</li>
                        <li><span class="k-icon k-i-image"></span>body-back.png</li>
                        <li><span class="k-icon k-i-image"></span>my-photo.jpg</li>
                    </ul>
                </li>
                <li data-expanded="true">
                    <span class="k-icon k-i-folder"></span>resources
                    <ul>
                        <li data-expanded="true">
                            <span class="k-icon k-i-folder"></span>pdf
                            <ul>
                                <li><span class="k-icon k-i-pdf"></span>brochure.pdf</li>
                                <li><span class="k-icon k-i-pdf"></span>prices.pdf</li>
                            </ul>
                        </li>
                        <li><span class="k-icon k-i-folder"></span>zip</li>
                    </ul>
                </li>
                <li><span class="k-icon k-i-html5"></span>about.html</li>
                <li><span class="k-icon k-i-html5"></span>contacts.html</li>
                <li><span class="k-icon k-i-html5"></span>index.html</li>
                <li><span class="k-icon k-i-html5"></span>portfolio.html</li>
            </ul>
        </li>
    </kendo-treeview>
</div>
Vue.use(TreeViewInstaller);

new Vue({
    el: "#vueapp"
})

Initializing with Webpack

  1. Install Kendo UI and add a theme.

    npm install --save @progress/kendo-ui
    npm install --save @progress/kendo-theme-default
  2. Install the Kendo UI TreeView package for Vue.

    npm install --save @progress/kendo-treeview-vue-wrapper
  3. Import the Kendo UI packages to the App component. If you use the Kendo UI components more than once in your application, add all Kendo UI-related files to the main.js file. If you use the Kendo UI components once in your application, add the Kendo UI-related files the component where they will be referred.

    import '@progress/kendo-ui'
    import '@progress/kendo-theme-default/dist/all.css'
    
    import { TreeView,
            TreeViewItem,
            TreeViewInstaller } from '@progress/kendo-treeview-vue-wrapper'
    
    Vue.use(TreeViewInstaller)
    
    new Vue({
       el: '#app',
       components: {
           TreeView
       }
    })

Features and Functionalities

Events

The following example demonstrates basic TreeView events. You can subscribe to all TreeView events by the handler name.

<div id="vueapp" class="vue-app">
    <kendo-hierarchicaldatasource ref="remoteDataSourceComponent"
                                  :transport-read-url="'https://demos.telerik.com/kendo-ui/service/Employees'"
                                  :transport-read-data-type="'jsonp'"
                                  :schema-model-id="'EmployeeId'"
                                  :schema-model-has-children="'HasEmployees'">
    </kendo-hierarchicaldatasource>
    <kendo-treeview data-source-ref="remoteDataSourceComponent"
                    :data-text-field="'FullName'"
                    :checkboxes="true"
                    :drag-and-drop="true"
                    @change="onChange"
                    @check="onCheck"
                    @collapse="onCollapse"
                    @dataBound="onDataBound"
                    @drag="onDrag"
                    @dragStart="onDragStart"
                    @dragEnd="onDragEnd"
                    @drop="onDrop"
                    @expand="onExpand"
                    @navigate="onNavigate"
                    @select="onSelect">
    </kendo-treeview>
</div>
Vue.use(TreeViewInstaller);
Vue.use(DataSourceInstaller);

new Vue({
    el: "#vueapp",
    methods: {
        onChange: function (ev) {
            console.log("Event :: change");
        },
        onCheck: function (ev) {
            console.log("Event :: check");
        },
        onCollapse: function (ev) {
            console.log("Event :: collapse");
        },
        onDataBound: function (ev) {
            console.log("Event :: dataBound");
        },
        onDrag: function (ev) {
            console.log("Event :: drag");
        },
        onDragStart: function (ev) {
            console.log("Event :: dragStart");
        },
        onDragEnd: function (ev) {
            console.log("Event :: dragEnd");
        },
        onDrop: function (ev) {
            console.log("Event :: drop");
        },
        onExpand: function (ev) {
            console.log("Event :: expand");
        },
        onNavigate: function (ev) {
            console.log("Event :: navigate");
        },
        onSelect: function (ev) {
            console.log("Event :: select");
        }
    }
})
In this article