【问题标题】:How to hide unselected checknode in the jstree如何在jstree中隐藏未选中的checknode
【发布时间】:2016-10-27 06:58:26
【问题描述】:

作为标题,我如何在 jstree 中隐藏未选中的检查节点。我只想在 jstree 中显示检查节点及其父节点。

非常感谢

【问题讨论】:

    标签: javascript php jquery jstree


    【解决方案1】:

    您将需要过滤掉完全选中的节点及其可能部分选中的父节点 - 如果选中的节点有一些未选中的兄弟节点。对于所有这些节点,将state.hidden 设置为true。然后重绘树。

    查看下面的代码,也可以查看演示 - Fiddle Demo

    $("#yourTreeId")
        .jstree('get_json', '#', {
            flat: true
        })
        .forEach(function(node) {
            if (!node.state.selected && $('#' + node.a_attr.id).find('.jstree-undetermined').length === 0) {
                $("#yourTreeId").jstree('get_node', node).state.hidden = true;
            }
        });
    
    $('#yourTreeId').jstree('redraw', true);
    

    【讨论】:

    • 嗨 Nikolay,如果我不想使用隐藏按钮并让它自动隐藏,我该怎么做?我曾尝试删除按钮单击功能,但没用。你有什么想法吗?
    • 那你打算怎么触发呢?在树加载时?
    • 嗨,我已经完成了。这是我的代码问题。你的代码可以工作。谢谢!
    • 当然,很高兴我能帮上忙!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多