Checkbox plugin - dont check child nodes when checking parent

4,302 views
Skip to first unread message

spartak

unread,
Aug 25, 2010, 8:12:08 AM8/25/10
to jsTree
Is there a way not automatically check all child nodes when their
parent node is checked ?

Stéphane

unread,
Sep 7, 2010, 5:29:32 AM9/7/10
to jsTree
+1 for this feature

I explain the situation, so you understand why it is necessary in some
cases.

I have a tree of "search agents" (configured with boolean searches)
I can organize them in folders and I display them using jstree.

I now implement a statistic features that displays graphs. I want to
be able to compare the counts on the folder to the count on a node.
that means selecting a folder + just one of its child.
Is it achievable with the new version of the tree? (currently
implemented with 0.99).
Keep up the good work, this tree is really awesome.

Regards,

Stéphane

vakata

unread,
Sep 17, 2010, 8:26:05 AM9/17/10
to jsTree
Hi,

There is such a solution here in the groups - a fellow member wrote a
custom checkbox plugin which does exactly that.
Or you can even achieve it using multple_select_modifier (ui) set to
"on", and a modified theme.

Kindest regards,
Ivan

Sadiq Naseer

unread,
Nov 4, 2013, 4:48:41 PM11/4/13
to jst...@googlegroups.com
Can someone please point me to the solution Ivan is referring to? I cant seem to find it.


Thanks.

Андрей Шерцингер

unread,
Nov 28, 2013, 1:37:23 AM11/28/13
to jst...@googlegroups.com
Hi. I also need same functional.

My condition - "checked parent" is not equal "all checked children"

My tree:
[_] Root
     [_] Parent
          [_] Child1
          [_] Child2
     [_] Parent2

When Child1 checked I need:

[*] Root
     [*] Parent
          [V] Child1
          [_] Child2
     [_] Parent2
(* - is "partial" mark)

and when Child2 checked I need:

[*] Root
     [*] Parent
          [V] Child1
          [V] Child2
     [_] Parent2

I wrote events handler that when I check Parent(with checked any child) it make:

[_] Root
     [V] Parent
          [_] Child1
          [_] Child2
     [_] Parent2

(automaticaly uncheck all childs and all his parent)
If again check Child1 - Parent will unchecked

But in two-state mode there are no partial marks on Root.
How to add "tri-state" marks on "my logic"


"my logic":

jquery('#tree').bind("change_state.jstree", function (e, data) {
   
if (!this._changeStateProcessActive) {
       
this._changeStateProcessActive = true;
       
var tree_instance = data.inst;
       
var node = data.rslt;
       
if (tree_instance.is_checked(node)) {
               
function recursiveUncheckChilds(node) {
                       
var childs = tree_instance._get_children(node);
                       
for (var i = 0; i < childs.length; i++) {
                                tree_instance
.uncheck_node(childs[i]);
                                recursiveUncheckChilds
(childs[i]);
                       
}
               
}
               
function recursiveUncheckParents(node) {
                       
if (node) {
                                tree_instance
.uncheck_node(node);
                                recursiveUncheckParents
(tree_instance._get_parent(node));
                       
}
               
}
                recursiveUncheckChilds
(node);
                recursiveUncheckParents
(tree_instance._get_parent(node));
                tree_instance
.close_node(node);
       
} else {
                tree_instance
.open_node(node);
       
}
       
this._changeStateProcessActive = null;
   
}
});
version: pre 1.0 fix 2

Maybe there is more elegant solution?

Thanks

Ben Black

unread,
Jul 17, 2014, 11:48:14 AM7/17/14
to jst...@googlegroups.com
Just set the three_state property to false.  For example:

                $("#tree").jstree({
                    "checkbox": { "three_state": false },
                    "core": {
                        "data": globals.treedata
                    },
                    "plugins": ["wholerow", "checkbox"]
                });
Reply all
Reply to author
Forward
0 new messages