Jstree:我怎样才能避免勾选禁用复选框?

时间:2016-06-14 14:13:56

标签: javascript jquery jstree

我有一棵树,其中几个节点被禁用。如果父节点已启用且其子节点处于禁用状态并且我尝试检查父节点,则检查所有节点。我只想要节点启用应该被检查。

$('#Tree').jstree({
    plugins: ["themes","checkbox","json_data","ui","types","real_checkboxes"],
    "checkbox" : {
        "keep_selected_style" : false,
        "tie_selection" : false,
        "three_state" : true,
        "real_checkboxes" : true
    },
    "core":
    {
        "themes": {
            "icons": false
        },
        "data":Products
    },
    "types":{
        "types":{
            "disabled" : {
                "check_node" : false,
                "uncheck_node" : false,
                "select_node": false,
                "open_node":   false,
                "close_node":  false,
                "create_node": false,
                "delete_node": false
            } ,
            "directory" : {

                "check_node" : false,
                "uncheck_node" : false
            },
            "default" : { 
                "check_node" : function () { 
                    if(node_should_be_disabled) return false; 
                    return true; 
                }, 
                "uncheck_node" : function () { 
                    if(node_should_be_disabled) return false; 
                    return true; 
                } 
            } 
        } 
    }
});

1 个答案:

答案 0 :(得分:0)

你可以试试这个

           $('.altGrup').jstree({
                "checkbox": {
                    three_state: false
                },
                "plugins": ["checkbox"]
            });