我想修改树的基础结构。我目前正在尝试更改主根(第一个(的位置。我试图将其设置在整个结构的顶部(首先出现的主要类别,然后是树的其余类别(。这是我的意思:https://i.stack.imgur.com/ygeg3.jpg 我不确定如果没有源代码。
我已经搜索了此功能,但没有成功。这是我发现的,到目前为止尝试。不确定它是否相关,但据我所知,应该有一些插件或类似的插件:https://www.jstree.com/api/#/?f=changed.jstree.jstreehttps://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调用,您可以在其中将Nodes parent更改为自己的喜欢。
API参考:https://www.jstree.com/api/#/?q=move_node&f=move_node(obj,%20PAR [,%20ppos, pos, callback, IS_>
示例:
var node = $('#documentation_tree').jstree("move_node", "NODE_ID", "#"); // # means root
注意:创建节点时,它们将返回创建的节点的ID,或者您可以传递id
参数(以及text
,icon
等(,您可以在其中说出所需的节点ID,然后以后使用它移动节点。
另外,似乎您希望其余的节点是您移动的节点的孩子,因此您必须相应地更改它。只需移动您想要成为父母的节点,然后将其余的节点移至该节点的孩子。