Skip to content

v1.16.0

Compare
Choose a tag to compare
@cheton cheton released this 24 Mar 04:16
· 27 commits to master since this release

Use a custom shouldLoadNodes function to return a boolean value to determine whether to load nodes on demand (07cec31, #30)

var tree = new InfiniteTree({
    el: document.querySelector('#tree'),
    data: [
        { // node
            id: '<unique-node-id>', // Required
            name: 'Node 0',
            loadNodes: true
        }
    ],
    shouldLoadNodes: function(parentNode) {
        return !parentNode.hasChildren() && parentNode.loadNodes;
    },
    loadNodes: function(parentNode, next) {
        var nodes = [
            {
                id: 'node1',
                name: 'Node 1'
            },
            {
                id: 'node2',
                name: 'Node 2'
            }
        ];
        setTimeout(function() {
            next(null, nodes, function() {
                // Completed
            });
        }, 1000);
    }
});