jsTree disable some of the checkboxes

血红的双手。 提交于 2019-12-05 05:25:13

Keep in mind unless you are using checkbox.tie_selection as false, selecting and checking are the same thing.

So you can simply call .disable_node() on the nodes you want disabled.


EDIT: Use the latest code from the repo (note - not 3.1.1, but the latest code): https://github.com/vakata/jstree/archive/master.zip

You can now specify the checkbox_disabled state:

<div id="jstree">
    <ul>
        <li data-jstree='{"checked":true}'>checked</li>
        <li data-jstree='{"checkbox_disabled":true}'>checked</li>
    </ul>
</div>

In JSON too of course:

{ "id" : "Test node", "state" : { "checkbox_disabled" : true } }

You can also change the disabled state of a checkbox at runtime using enable_checkbox(node) and disable_checkbox(node).

To completely hide checkbox from the specific node, add following JS code

$('#tree_2').on('ready.jstree', function () {
  $("#tree_2").jstree().get_node("node1_id").a_attr["class"] = "no_checkbox";
  $("#tree_2").jstree().get_node("node2_id").a_attr["class"] = "no_checkbox";

....
});

and in CSS, add the following style

.no_checkbox > i.jstree-checkbox {
	display: none;
}

It will completely hide checkbox from provided node id, this worked like a charm for me. Thanks to this link.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!