作为标题,我如何隐藏 jstree 中未选中的检查节点。我只想在 jstree 中显示检查节点及其父节点。
非常感谢
最佳答案
如果选定的节点有一些未选定的同级节点,您将需要过滤掉完全选定的节点及其可能部分选定的父节点。对于所有这些节点,将 state.hidden
设置为 true
。然后重画树。
请参阅下面的代码,另请查看演示 - Fiddle Demo
$("#yourTreeId")
.jstree('get_json', '#', {
flat: true
})
.forEach(function(node) {
if (!node.state.selected && $('#' + node.a_attr.id).find('.jstree-undetermined').length === 0) {
$("#yourTreeId").jstree('get_node', node).state.hidden = true;
}
});
$('#yourTreeId').jstree('redraw', true);
关于javascript - 如何隐藏jstree中未选中的checknode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40278142/