我正在使用jstree jquery。我希望动态选择onload选择所有节点。
或者如何在xml文件中设置checked =“true或false”就像state =“open or close”..
可以帮助任何人......
答案 0 :(得分:8)
要在使用jstree
插件运行checkbox
时检查所有节点,请在树控件上调用check_all()
,或在顶级节点上调用check_node()
以检查所有节点特别的分支。
示例:
$(document).ready(function() {
// select the whole jstree control
$("#tree_control").jstree("check_all");
// select a whole branch:
$('#tree_control').jstree("check_node", "#top_level_node_id");
});
答案 1 :(得分:2)
使用此代码
$(".jstree li[role=treeitem]").each(function () {
$(".jstree").jstree('select_node', this)
});
并且onload使用此代码
$(".jstree").jstree().on('loaded.jstree', function () {
$(".jstree li[role=treeitem]").each(function () {
$(".jstree").jstree('select_node', this)
});
})
答案 2 :(得分:1)
要打开节点的所有子节点,只需调用:
open_all('#selector-to-the-node');