Shimmy Weitzhandler
Shimmy Weitzhandler

Reputation: 104821

jsTree select checkbox independent to hierarchy

I'm using jsTree with checkboxes, and it checks all the parent nodes when selecting a child.

Is there a way to select each node individually regardless to the hierarchy?

Currently:

enter image description here

Desired:

enter image description here

Here's my code:

$(function () {
 $('#tree').jstree({
  "checkbox": {
   "two_state": true,
   "real_checkboxes": true,
   //this is supposed to fix it but it doesn't
   "override_ui": true
  },
  "plugins": ["themes", "ui", "checkbox"]
 });
 $('#tree').jstree("hide_icons");
 $('#tree').jstree("hide_dots");   
});

Here is the documentation.

Upvotes: 3

Views: 2890

Answers (2)

Asif Nowaj
Asif Nowaj

Reputation: 356

Using 3.3.8 version of jsTree, yes, instead of using two_state:true, use "three_state": false in checkbox plugins. @shakib is right above. For complete and working source code, you can refer https://everyething.com/Example-of-jsTree-to-get-all-checked-nodes#GetAllCheckedNodeWithTriStateDisabled

Upvotes: 0

shakib
shakib

Reputation: 5469

For the current master version in GitHub (2.0.0 alpha),

$(function () {
    $('#demo1').jstree({
        "checkbox": {
            "three_state": false
        },
        "core": {
            "themes": {
                dots: false,
                icons: false
            }
        },
        "plugins": ["html_data", "themes", "ui", "checkbox"]
    });
});

hope this helps.

Upvotes: 5

Related Questions