TreeView

The TreeView widget is a tree-like representation of textual data.

Included in: dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/tree_view
Export: default
TreeView interactive configuration
Copy Code
Copy to Codepen
$("#treeview").dxTreeView({
});

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

jQuery
JavaScript
HTML
var species = [
    { id: 1, parentId: 0, text: "Species" },
    { 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" }
];
$(function () {
    $("#treeView").dxTreeView({
        dataSource: species,
        dataStructure: 'plain'
    });
});
<div id="treeView"></div>
Angular
HTML
TypeScript
<dx-tree-view
    [dataSource]="species"
    dataStructure="plain">
</dx-tree-view>
export class AppComponent {
    species = [
        // ...   
    ];
}
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-tree-view="{
        dataSource: species,
        dataStructure: 'plain'
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller("DemoController", function ($scope) {
        $scope.species = [
            // ...   
        ];
    });
Knockout
HTML
JavaScript
<div data-bind="dxTreeView: {
    dataSource: species,
    dataStructure: 'plain'
}"></div>
var viewModel = {
    species: [
        // ...
    ]
};
ko.applyBindings(viewModel);
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().TreeView()
    .ID("treeView")
    .DataSource(Species)
    .DataStructure(TreeViewDataStructure.Plain)
)
@(Html.DevExtreme().TreeView() _
    .ID("treeView") _
    .DataSource(Species) _
    .DataStructure(TreeViewDataStructure.Plain)
)

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the topics in the Installation section.

NOTE
The TreeView 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

See Also
Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the TreeView widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

See Also

Node

A TreeView node.

This section describes the contents of a TreeView node object. Such objects can be accessed using the getNodes() method and within functions handling the events whose name begins with item....

See Also

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