Undetermined as selected

2,223 views
Skip to first unread message

Eric Krenz

unread,
Jul 17, 2014, 12:43:02 PM7/17/14
to jst...@googlegroups.com
Is there a way to cause undetermined nodes to be returned by get_selected?

Or is there instead a way to set the nodes that would have been set to the undetermined state to instead change to the selected/checked state?

Ivan Bozhanov

unread,
Jul 17, 2014, 3:59:24 PM7/17/14
to jst...@googlegroups.com
I am not sure what you need - sorry. Take a look at the checkbox cascade option - you can disable undetermined altogether. What you need can be achieved by disabling cascading altogether and using an event handler - when selection changes - get all selected nodes and select their parents too, if that is what you need (which would effectively set nodes that would otherwise be undetermined to checked, but without selecting their children).
I will be able to help further if you clarify the logic behind your application.

Best regards,
Ivan

Eric Krenz

unread,
Jul 17, 2014, 4:51:44 PM7/17/14
to jst...@googlegroups.com
I apologize for the lack of clarity.

Basically what I'm looking for is to on the get_selected call:

[o] root
 
[o] item 1
   
[x] subitem1
 
  [ ] subitem2
 
[ ] item 2


where:
x
= checked
0 = undetermined

I want to return all results that are checked OR undetermined (x OR o).

on my call of get_selected, I am only getting the id of subitem1, where I would like the id's of subitem1, item1, and root.

Ivan Bozhanov

unread,
Jul 18, 2014, 12:36:10 AM7/18/14
to jst...@googlegroups.com
If I were you I'd probably do it this way:

var selected = instance.get_selected(), i, j;
for(i = 0, j = selected.length; i < j; i++) {
  selected = selected.concat(instance.get_node(selected[i]).parents);
}
selected = $.vakata.array_unique(selected);
selected; // this is what you need

There is no way to get this from the tree, but if you want - you can create a very small plugin and override get_selected with the above. Otherwise - simply use this code where you process selected nodes.

Best regards,
Ivan

Eric Krenz

unread,
Jul 18, 2014, 12:12:49 PM7/18/14
to jst...@googlegroups.com
This is exactly what I needed, thank you.

erick loyo

unread,
Dec 22, 2015, 8:49:05 AM12/22/15
to jsTree
hello everyone, i have a week trying to do this and i hadnt found anything, i found this post but i dont know where should i put this code, im sorry about that dumb question but i am newbie on this. i rlly want a hand here, thank all

Владислав Цмокалюк

unread,
Dec 15, 2020, 10:55:16 AM12/15/20
to jsTree

Hello.  Footer has selected nodes. How can a do this? 
снимок.png
пятница, 18 июля 2014 г. в 07:36:10 UTC+3, ivan.b...@gmail.com:
Reply all
Reply to author
Forward
0 new messages