2014-01-19 78 views
1

创建复选框复选框树根据jstree所有节点包括父母的childNodes在默认情况下有旁边的复选框。如何只在叶节点

jstree

,但我想这样的事情jqueryeasyUI tree 那里有瀑布和叶节点检查选项。

编辑: 下面给出了一个示例。

<div id="jstree"> 
    <!-- in this example the tree is populated from inline HTML --> 
    <ul> 
     <li class="node" >Root node 1 
     <ul> 
      <li id="child_node_1">Child node 1</li> 
      <li>Child node 2</li> 
     </ul> 
     </li> 
     <li class="node" >Root node 2</li> 
    </ul> 
    </div> 
    <button>demo button</button> 

    <!-- 4 include the jQuery library --> 
    <script src="dist/libs/jquery.js"></script> 
    <!-- 5 include the minified jstree source --> 
    <script src="dist/jstree.min.js"></script> 
    <script> 
    $(function() { 
    // 6 create an instance when the DOM is ready 
    $("#jstree").jstree({ 
     "checkbox": { 
      "keep_selected_style": false 
     }, 
     "plugins": ["checkbox"] 
    }); 

    $(".node").find('> a > .jstree-checkbox').remove() 
}); 
    </script> 

现在我无法移除父节点的复选框,但在展开时会创建旁边的复选框。

有谁知道是否jstree提供的选项只检查叶节点,而不是级联检查? 如果是这样,请分享想法。

回答

0

当我修改jstree.min.js three_state:1,从

three_state:0 它的工作。

的文件说

/** * 一个boolean值,指示单击节点上的任何地方应单击该复选框作用。默认为true。 * @name $ .jstree.defaults.checkbox.whole_node * @plugin复选框 */

2

我觉得从this post最好的解决办法是为以下

CSS的解决方案将被罚款

#id-here .jstree-open > .jstree-anchor > .jstree-checkbox, 
#id-here .jstree-closed > .jstree-anchor > .jstree-checkbox { display:none; } 
相关问题