FancyTree:如何展开所有 nested/subsequent 个节点?不仅是当前节点

FancyTree: How do I Expand all nested/subsequent nodes? Not only current nodes

当我使用以下 Fancytree even 操作时:

$(document).on('click', '.expand-all', function () {
                $.ui.fancytree.getTree().expandAll();
            });

Fancytree 只扩展当前节点,不扩展更多级别的 sub/nested 节点。假设以下情况不同时发生:

如何在单个事件中实现该目标?

我已经想通了,是这样做的:

$(document).on('click', '.expand-all-nested', function (e) {
            expandNodes();

            function expandNodes() {
                $.ui.fancytree.getTree("#treegrid").visit(function (node) {
                    if (node.isLazy() && !node.isExpanded() && !node.isLoading()) {
                        node.setExpanded(true).done(() => {
                                console.log('Auto Expanding Children');
                                expandNodes()
                            }
                        ).catch(function (error) {
                            //Error occurred. Trying re-fetching data
                            console.log('Error occurred. Trying re-fetching data');
                            setTimeout(function () {
                                node.load(true).done(() => {
                                    console.log('Successfully Re-fetched errored data');
                                }).catch(function () {
                                    console.log('Couldn\'t Re-fetch errored data');
                                });
                            }, 700);
                        })
                    }
                });
            }
        });