仅当单击标签上的复选框时,才检查取消选中的jstree

时间:2017-03-25 08:25:02

标签: javascript jstree

我使用jsTree渲染了一个树视图,如果单击复选框图标而不是在节点标签上,我如何检查/取消选中节点?

2 个答案:

答案 0 :(得分:1)

对我有用的只是删除jstree选项位中的“批发”:

所以,来自

"plugins": ["wholerow", "checkbox"],

收件人:

"plugins": ["checkbox"],

因此,整个jstree配置如下:

$('#testTree').jstree({
    "core": {
        "themes": {
        "theme": "default",
        "dots": false,
        "icons": false
        },
        "data": @Html.Raw(ViewBag.Menu)
    },
    "checkbox": {
        "keep_selected_style": false,
    },
    "plugins": ["checkbox"],
});

答案 1 :(得分:0)

我找到了回答我自己的问题 设置以下属性后,它的行为与预期一致。

        $('#testTree').jstree({ 
    core: {
      data: getData, 
      check_callback: false
    }, 
    checkbox: {       
      three_state : false, 
      whole_node : false,//Used to check/uncheck node only if clicked on checkbox icon, and not on the whole node including label
      tie_selection : false
    },
    plugins: ['checkbox']
})