TreeView

A widget displaying specified data items as a tree.

Included in: dx.webappjs.js, dx.all.js

You can create a widget using one of the following approaches.

  • jQuery
    Use the dxTreeView jQuery plug-in.

    HTML
    <div id="treeView"></div>
    JavaScript
    var treeViewData = [
        { id: 1, parentId: 0, text: "Animals" },
        { id: 2, parentId: 1, text: "Cat" },
        { id: 3, parentId: 1, text: "Dog" },
        { id: 4, parentId: 1, text: "Cow" },
        { id: 5, parentId: 2, text: "Abyssinian" },
        { id: 6, parentId: 2, text: "Aegean cat" },
        { id: 7, parentId: 2, text: "Australian Mist" },
        { id: 8, parentId: 3, text: "Affenpinscher" },
        { id: 9, parentId: 3, text: "Afghan Hound" },
        { id: 10, parentId: 3, text: "Airedale Terrier" },
        { id: 11, parentId: 3, text: "Akita Inu" },
        { id: 12, parentId: 0, text: "Birds" },
        { id: 13, parentId: 12, text: "Akekee" },
        { id: 14, parentId: 12, text: "Arizona Woodpecker" },
        { id: 15, parentId: 12, text: "Black-chinned Sparrow" }
    ];
    $("#treeView").dxTreeView({
        dataSource: treeViewData,
        dataStructure: 'plain'
    });
  • Knockout
    Add a div element and apply the dxTreeView binding to this element.

    HTML
    <div data-bind="dxTreeView: {
        dataSource: treeViewData,
        dataStructure: 'plain'
    }"></div>
  • Angular
    Add a div element and apply the dx-tree-view directive to this element.

    HTML
    <div dx-tree-view="{
        dataSource: treeViewData,
        dataStructure: 'plain'
    }"></div>

Note that DevExtreme widgets require you to link the jQuery and Globalize libraries to your application. If you use the Knockout or Angular approach, the Knockout or Angular library is also required.

See Also

Since the dxTreeView widget is used to display multiple items, it supports common Collection Container widget functionality. You can find detailed information on the principles of working with the widget in the dxTreeView section of the Collection Container Widgets article.

NOTE: The dxTreeView widget requires each data source item to contain at least a key field. Thus, the widget does not support data sources consisting of value items.

View Demo

Watch Video

Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the dxTreeView widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events exposed by this widget.

Default Item Template

This section lists the data source fields that are used in a default item template.

By default, a predefined item template is applied to display the items of this widget. This template is based on certain fields of the data source provided for this widget. Below is the list of these fields. If the default item template is not appropriate for your task, implement a custom item template based on these or other fields of your data source.

See Also