我正在使用IGtree。我在树中有数据,直到树中的4个级别。最初,所有节点都会折叠。在展开任何特定节点时,它的所有子节点也应该展开到最后一层
发布于 2019-04-12 16:48:25
let nodes = $("#configTree").igTree("children", event.element);
if(nodes) {
nodes.forEach((node1)=>{
$("#configTree").igTree("expand", node1.element);
})
}发布于 2019-04-05 20:30:43
其中一个选项是处理nodeExpanding事件,以区分根节点并找到它们的父节点。然后展开每个节点和所有节点,直到根节点。下面是一个代码片段:
$(document).on("igtreenodeexpanding", "#tree", function (evt, ui) {
// this ensures the expanding node is on root level.
if (ui.node.path.indexOf(ui.owner.options.pathSeparator) <= -1) {
// Select all the nodes whcih contain children
// Here you can play with the path if you want to limit expanding to a certain level
var nodes = $(ui.node.element).find("li[data-role='node'].ui-igtree-parentnode");
for (var i = 0; i < nodes.length ; i++) {
var node = $(nodes[i]);
ui.owner.expand(node);
ui.owner.expandToNode(node);
// or you can use:
// $("#tree").igTree("expand", node);
// $("#tree").igTree("expandToNode", node);
}
}
});希望这能有所帮助。
https://stackoverflow.com/questions/55476804
复制相似问题