jsTree禁用某些复选框 [英] jsTree disable some of the checkboxes

查看:72
本文介绍了jsTree禁用某些复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用具有复选框插件的jsTree(3.1.0+)是否可以允许并非所有复选框都处于选中状态-禁用其中某些复选框?

Using jsTree (3.1.0+) with checkbox plugin is it possible to allow not all checkboxes to check - disable some of them?

我在 jstree disable复选框中找到了旧版本jsTree的解决方案,但它在jsTree 3.1.0+版本.

I found solution for old versions of jsTree here jstree disable checkbox but it didn't work on jsTree 3.1.0+ versions.

隐藏复选框的解决方法 jsTree隐藏复选框正在工作,但是如果我单击该文件夹,则隐藏复选框仍会被选中.

Solution of hiding checkbox jsTree Hide Checkbox is working, but if I click on the folder, hidden checkbox will be checked anyway.

谢谢.

推荐答案

请记住,除非您将checkbox.tie_selection用作false,否则选择和检查是相同的.

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

因此,您只需在要禁用的节点上调用.disable_node().

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

编辑:使用仓库中的最新代码(请注意-不是3.1.1,而是最新代码): https://github.com/vakata/jstree/archive/master.zip

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

您现在可以指定checkbox_disabled状态:

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

当然也使用JSON:

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

您还可以在运行时使用enable_checkbox(node)disable_checkbox(node)更改复选框的禁用状态.

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

这篇关于jsTree禁用某些复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆