是否可以选择将最先(主要)节点移动到结构顶部?

Is there an option to move the most first(main) node on the top of the structure?

我想修改树的基础结构。 我目前正在尝试更改主根(第一个)的位置。我试图将它设置在整个结构的顶部(主要类别首先出现,然后是树的其余部分)。 这就是我的意思:https://imgur.com/a/QrAA4Zd 我不确定不接触源代码是否可行。

我已经在搜索此功能,但没有成功。这是我到目前为止发现和尝试的。不确定它是否相关,但据我了解应该有一些插件或类似的东西:https://www.jstree.com/api/#/?f=changed.jstree https://www.jstree.com/plugins/

这是目前的代码:

$('#documentation_tree')
    .on('open_node.jstree', function () {
        $('.tooltips').tooltip();
    })
    .jstree({
        "core": {
            "themes": {
                "variant": "large"
            },
        },
        "types": {
            "default": {
                "icon": "fa fa-folder icon-state-warning icon-lg"
            },
            "file": {
                "icon": "fa fa-file icon-state-warning icon-lg"
            }
        },
        "plugins": ["types"]
    });

这段代码工作正常,但这不是我想要完成的。

您有 mode_node API 调用,您可以在其中根据自己的喜好更改父节点。

API参考:https://www.jstree.com/api/#/?q=move_node&f=move_node(obj,%20par%20[,%20pos,%20callback,%20is_loaded])

示例:

var node = $('#documentation_tree').jstree("move_node", "NODE_ID", "#"); // # means root

注意:当您创建节点时,它们将 return 创建节点的 ID 或者您可以传递 id 参数(以及 texticon等等)你可以在这里说出你想要的节点 ID,然后用它来移动节点。

此外,您似乎希望其余节点成为您移动的节点的子节点,因此您必须相应地更改它。只需移动您想要成为父节点的节点,并将其余节点移动为该节点的子节点。