【问题标题】:how to create a checkbox tree with checkbox only at leaf nodes如何仅在叶节点处创建带有复选框的复选框树
【发布时间】:2014-01-19 12:38:07
【问题描述】:

根据jstree,所有的节点包括父节点和子节点都会默认旁边有复选框。

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是否提供了只检查叶节点而不是级联检查的选项吗? 如果是这样,请分享想法。

【问题讨论】:

    标签: javascript jquery jquery-ui tree jstree


    【解决方案1】:

    我认为this post 的最佳解决方案如下

    CSS 解决方案会很好

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

    【讨论】:

      【解决方案2】:

      当我修改了 jstree.min.js 三态:!1,来自

      三个状态:!0 成功了。

      文档说

      /** * 一个布尔值,指示单击节点上的任何位置是否应作为单击复选框。默认为true。 * @name $.jstree.defaults.checkbox.whole_node * @plugin 复选框 */

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-18
        • 2012-02-23
        • 2011-07-03
        • 2011-07-10
        相关资源
        最近更新 更多