FancyTree > 将父节点扩展到活动子节点

FancyTree > Expand parents to an active subnode

我有一个转换为 FancyTree 的列表。 FancyTree 已设置为 activeVisible:true,这意味着包含活动节点的树将从活动节点扩展到最顶层的父节点。但这不起作用,所以我想我错过了一些东西,但无法弄清楚这可能是什么。

初始化:

$("div[id^=msctree]").fancytree({
    checkbox: true,
    selectMode: 1,
    activeVisible: true,
    extensions: ['contextMenu'],
    contextMenu: {
        menu: {
            'edit': { 'name': 'Edit', 'icon': 'edit' },
        },
        actions: function(node, action, options) {
            if ( action == "edit" ) {
                ...someAction...
            }
        }
    }
});

榜单:

<div id="msctree">
 <ul>
  <li>
   Topmost parent
   <ul>
    <li data-active="true" data-expanded="true">
     Subnode
     <ul>
       <li>List with further dubs</li>
     </ul>
    </li>
   </ul>
  </li>
 </ul>
</div>

带有 data-active="true" 和 data-expanded="true" 的 li 已扩展,但最顶层的父级不是,我认为这是错误的行为,因为我已将 activeVisible 设置为 true。 这是为什么?如何配置 fancetree() 插件来执行我想要的操作?

提前致谢。

FancyTree 有一个这样做的内置功能,但它似乎不起作用。所以这个不错的插件的开发者为此开了一个问题。在问题解决之前,可以使用我的解决方法。

init: function(event, data) {
        var activeJumpNode = data.tree.getActiveNode();
        if ( activeJumpNode ) {
            var treeObj = $("div[id^=msctree]").fancytree("getTree");
            var jumpToNode = treeObj.findFirst(function(node) {
                return node === activeJumpNode;
            });
            jumpToNode.setActive();
            jumpToNode.setFocus();
            $(treeObj.$container).focus();
        }           
    }

这会将所有父节点扩展为活动子节点。