jsTree选择复选框,独立于层次结构

问题描述 投票:2回答:2

我将jsTree与复选框一起使用,并且在选择子级时会检查所有父级节点。

是否有一种方法可以单独选择每个节点而不管层次结构如何?

当前:

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9iZndxSy5wbmcifQ==” alt =“在此处输入图像描述”>

所需:

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9yb0kyVi5wbmcifQ==” alt =“在此处输入图像描述”>

这是我的代码:

$(function () {
 $('#tree').jstree({
  "checkbox": {
   "two_state": true,
   "real_checkboxes": true,
   //this is supposed to fix it but it doesn't
   "override_ui": true
  },
  "plugins": ["themes", "ui", "checkbox"]
 });
 $('#tree').jstree("hide_icons");
 $('#tree').jstree("hide_dots");   
});

Here是文档。

javascript jquery checkbox selection jstree
2个回答
4
投票

对于GitHub(2.0.0 alpha)中的当前主版本,

$(function () {
    $('#demo1').jstree({
        "checkbox": {
            "three_state": false
        },
        "core": {
            "themes": {
                dots: false,
                icons: false
            }
        },
        "plugins": ["html_data", "themes", "ui", "checkbox"]
    });
});

希望这会有所帮助。


0
投票

使用jsTree的3.3.8版本,是的,而不是使用two_state:true,请在复选框插件中使用"three_state": false。@shakib就在上方。有关完整且有效的源代码,请参考https://everyething.com/Example-of-jsTree-to-get-all-checked-nodes#GetAllCheckedNodeWithTriStateDisabled

© www.soinside.com 2019 - 2024. All rights reserved.