Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSTree - Disable automatic selection of children on load

I need to disable the automatic selection of all children at loading time. If I set a parent node with selected parameter to true, it will select all of its children, but I want to have only the parent node selected.

$('#tree_groups').jstree({
        'plugins': ["wholerow", "checkbox", "types"],
        'core': {
            'data': [{
                "id": "0-14089749041",
                "text": "Sport",
                "state": {
                    "selected": true,
                },
                "children": [{
                "id": "14089749041-14089751330",
                "text": "Pallacanestro",},
                {"id": "14089749041-14089751110",
                "text": "Tennis",},
            ]},
        "types" : {
            "default" : {
                "icon" : "fa fa-group icon-state-warning icon-lg"
            },
            "file" : {
                "icon" : "fa fa-file icon-state-warning icon-lg"
            }
        }
    });

Thanks

like image 480
Gabriele Pieretti Avatar asked Mar 18 '23 15:03

Gabriele Pieretti


1 Answers

I found the answer by myself, I've just set the three_state of checkbox plugin to false.

$('#tree_groups').jstree({
    'plugins': ["wholerow", "checkbox", "types"],
    'core': {
        'data': [{
            "id": "0-14089749041",
            "text": "Sport",
            "state": {
                "selected": true,
            },
            "children": [{
            "id": "14089749041-14089751330",
            "text": "Pallacanestro",},
            {"id": "14089749041-14089751110",
            "text": "Tennis",},
        ]},
    "checkbox" : {
            "three_state" : false,
        },
    "types" : {
        "default" : {
            "icon" : "fa fa-group icon-state-warning icon-lg"
        },
        "file" : {
            "icon" : "fa fa-file icon-state-warning icon-lg"
        }
    }
});
like image 145
Gabriele Pieretti Avatar answered Apr 02 '23 09:04

Gabriele Pieretti