【问题标题】:FancyTree > Expand parents to an active subnodeFancyTree > 将父节点展开到活动子节点
【发布时间】:2015-10-30 14:07:05
【问题描述】:

我有一个转换为 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


    【解决方案1】:

    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();
            }           
        }
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多