How to disable a tree node in checkbox theme

4,811 views
Skip to first unread message

Lucy

unread,
Jun 15, 2010, 8:15:25 PM6/15/10
to jsTree
Hi there,
Has any body ever tried to disable a tree node (or make it invisible)
in checkbox theme?
I need to do this to prevent users from reselecting the same node
after they tick and save to a short list.
Thanks
Lucy

vakata

unread,
Jun 16, 2010, 3:20:10 AM6/16/10
to jsTree
Use the latest commit (as it has some bugs fixed and you can lose the
UI plugin too) and then use the types plugin and:

1) Either give your disabled nodes a type and set it to:
"disabled" : {
"check_node" : false,
"uncheck_node" : false
}
// Your disabled nodes should have their "rel" attributes set to
"disabled"
// You can change that name and the attribute if you will - read the
types plugin docs

2) Or use the default type:
"default" : {
"check_node" : function () {
if(node_should_be_disabled) return false;
return true;
},
"uncheck_node" : function () {
if(node_should_be_disabled) return false;
return true;
}
}

I hope this helps :)

Cheers,
Ivan

Pavel Bariev

unread,
Aug 13, 2014, 8:56:53 AM8/13/14
to jst...@googlegroups.com
Hi! Is there a similar way for version 3?

Ivan Bozhanov

unread,
Aug 13, 2014, 10:33:04 AM8/13/14
to jst...@googlegroups.com
There is the `enable_node` and `disable_node` functions, or you can use CSS to hide the checkbox if that is what you need, but disable_node will probably what you need.

Best regards,
Ivan

Ifeanyi Agu

unread,
Nov 14, 2014, 12:50:14 PM11/14/14
to jst...@googlegroups.com
Does the disable_node and enable_node work with types?

Ivan Bozhanov

unread,
Nov 15, 2014, 2:03:02 AM11/15/14
to jst...@googlegroups.com
I am not sure I get the question - there is no conflict between the two. However you can not set any state properties (opened, selected, disabled) form the type, the types plugin is not used for this.

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages