jstree禁用复选框 [英] jstree disable checkbox
问题描述
我目前正在使用JS Tree插件和相关的复选框插件的一些POC。
对于某些节点,我需要检查复选框默认情况下禁用任何进一步的选择。我发现该函数隐藏复选框
I am currently working on some POC using JS Tree plugin and related check box plugin. For certain nodes I need to check the check box by default and disable any further selection.I found the function to hide the check box
.bind("load_node.jstree", function (e, data) {
$(this).find('li[rel!=file]').find('.jstree-checkbox:first').hide();
});
而不是完全隐藏复选框我想找到一种方法来禁用某些节点的复选框
instead of hiding the check box completely I want to find a way to disable check box for certain nodes
推荐答案
您需要定义一个禁用类型(使用types插件),然后将该类型分配给所需的节点。
You will need to define a "disabled" type (using the types plugin) and then assign that type to the desired node.
以禁用类型定义为例:
"types" : {
"types": {
"disabled" : {
"check_node" : false,
"uncheck_node" : false
}
}
}
和类型配置:
$.jstree._reference('#tree').set_type("disabled", "#node5");
有关类型插件的更多信息可以找到此处,您还可以查看此Google群组的更多信息禁用复选框
More info on the types plugin can be found here and you can also check this google group with more info on disabling checkboxes
希望它有帮助!
这篇关于jstree禁用复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!