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
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
Share Improve this question edited Aug 26, 2014 at 15:36 Gabriele Pieretti asked Aug 26, 2014 at 15:19 Gabriele PierettiGabriele Pieretti 1611 silver badge8 bronze badges 1- Please share you code whatever you tried. – hriziya Commented Aug 26, 2014 at 15:26
2 Answers
Reset to default 7I 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"
}
}
});
I have looked for article which contains proper answer on this problem. This can be solved on easiest possible way. On jstree instance just add an event as i showed below
.on('changed.jstree', function (e, data) {
if (data.event === undefined) return false;
})