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.

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
    });
});

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.

JavaScript
$(function() {
    $("#treeViewContainer").dxTreeView({
        createChildren: function (parentNode) {
            var d = $.Deferred();
            $.get("http://url/to/the/service", parentNode).done(function (result) {
                d.resolve(result);
            });
            return d.promise();
        },
        dataStructure: 'plain'
    });
});

View Demo

See Also