All docs
V19.1
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
The page you are viewing does not exist in version 22.2.
22.1
The page you are viewing does not exist in version 22.1.
21.2
The page you are viewing does not exist in version 21.2.
21.1
The page you are viewing does not exist in version 21.1.
20.2
The page you are viewing does not exist in version 20.2.
20.1
The page you are viewing does not exist in version 20.1.
19.2
19.1
18.2
18.1
17.2
A newer version of this page is available. Switch to the current version.

DevExtreme jQuery - Enhance Performance on Large Datasets

If the TreeView performance is low, consider enabling the Virtual Mode. In this mode, the TreeView loads a set of child nodes once their parent node is expanded. The Virtual Mode can be enabled only if your data source satisfies the following conditions.

To enable the Virtual Mode, set the virtualModeEnabled option to true.

jQuery
JavaScript
var plainData = [
    { id: 1,  text: 'Fruits',     parentId: -1 },
    { id: 11, text: 'Apples',     parentId: 1, hasItems: false },
    { id: 12, text: 'Oranges',    parentId: 1, hasItems: false },
    { id: 2,  text: 'Vegetables', parentId: -1 },
    { id: 21, text: 'Cucumbers',  parentId: 2, hasItems: false },
    { id: 22, text: 'Tomatoes',   parentId: 2, hasItems: false }
];

$(function() {
    $("#treeViewContainer").dxTreeView({
        dataSource: plainData,
        dataStructure: 'plain',
        virtualModeEnabled: true,
        rootValue: -1
    });
});
Angular
HTML
TypeScript
<dx-tree-view
    [dataSource]="plainData"
    dataStructure="plain"
    [virtualModeEnabled]="true"
    [rootValue]="-1">
</dx-tree-view>
import { DxTreeViewModule } from "devextreme-angular";
// ...
export class AppComponent {
    plainData = [
        { id: 1,  text: 'Fruits',     parentId: -1 },
        { id: 11, text: 'Apples',     parentId: 1, hasItems: false },
        { id: 12, text: 'Oranges',    parentId: 1, hasItems: false },
        { id: 2,  text: 'Vegetables', parentId: -1 },
        { id: 21, text: 'Cucumbers',  parentId: 2, hasItems: false },
        { id: 22, text: 'Tomatoes',   parentId: 2, hasItems: false }
    ];
}
@NgModule({
    imports: [
        // ...
        DxTreeViewModule
    ],
    // ...
})

View Demo

If the Virtual Mode does not meet your requirements, you can get full control over nodes and how to load them in the createChildren function. This function will be called at the beginning of the widget's lifetime and each time a user expands a node whose child nodes have not been loaded yet.

jQuery
JavaScript
$(function() {
    $("#treeViewContainer").dxTreeView({
        createChildren: function (parentNode) {
            var d = $.Deferred();
            $.get("http://url/to/the/service", {
                    parentId: parentNode ? JSON.stringify(parentNode.key) : "0"
                })
                .done(function (result) {
                    d.resolve(result);
                });
            return d.promise();
        },
        dataStructure: 'plain'
    });
});
Angular
HTML
TypeScript
<dx-tree-view
    [createChildren]="createChildren"
    dataStructure="plain">
</dx-tree-view>
import { ..., Inject } from "@angular/core";
import { HttpClient, HttpClientModule, HttpParams } from "@angular/common/http";
import "rxjs/add/operator/toPromise";
import { DxTreeViewModule } from "devextreme-angular";
// ...
export class AppComponent {
    constructor(@Inject(HttpClient) httpClient: HttpClient) { }
    createChildren = (parentNode) => {
        let params: HttpParams = new HttpParams()
            .set("parentId", parentNode ? JSON.stringify(parentNode.key) : "0");
        return httpClient.get("http://url/to/the/service", {
                params: params
            })
            .toPromise();
    }
}
@NgModule({
    imports: [
        // ...
        DxTreeViewModule,
        HttpClientModule
    ],
    // ...
})

View Demo

See Also