gpt4 book ai didi

javascript - jsTree : How to get all nodes from jstree?

转载 作者:可可西里 更新时间:2023-11-01 02:17:32 26 4
gpt4 key购买 nike

如何获取jsTree中的所有节点?

我正在用 xml 构建 jsTree

Root
-----A
-----A1
-----A1.1
-----A1.2
-----A2
-----`A2.1`
-----A2.2

-----B
-----B1
-----B2

-----C
-----C1
-----C1.1
-----C2.2

我希望 jsTree 中存在的所有节点 (ID) 的数组如下所示

预期输出:[Root, A, A1, A1.1, A1.2, A2, A2.1, A2.2, B, B1, B2, C, C1, C1.1, C2。 2]

最佳答案

来自 documentation :

.get_json ( node , li_attr , a_attr )

This function returns an array of tree nodes converted back to JSON.

有关相同功能的更多信息来自 this doc :

This function traverses the whole tree and exports it as JSON. Refer do the data sources section to see the format of the output.

If you specify a node as the first argument, only that node and its children are included in the export, otherwise the whole tree is exported.

只需搜索,您就会找到! :)

关于javascript - jsTree : How to get all nodes from jstree?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10296410/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com