【问题标题】:FancyTree: How do I Expand all nested/subsequent nodes? Not only current nodesFancyTree:如何展开所有嵌套/后续节点?不仅是当前节点
【发布时间】:2021-08-21 10:24:46
【问题描述】:

当我使用以下 Fancytree 偶数动作时:

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

Fancytree 仅扩展当前节点,但不扩展更多级别的子/嵌套节点。假设以下情况不同时发生:

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

【问题讨论】:

  • 你能让这个可运行吗?

标签: javascript jquery treeview fancytree


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-08
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多