JSTree check node

3,207 views
Skip to first unread message

Alkingson

unread,
Jan 26, 2011, 3:29:11 PM1/26/11
to jsTree
Hi,
I am using jstree 1.0 version.
Everything is working fine and its awesome and very fast compared to
MSAJAX tree.
In my tree i am using checkbox plugin.

I have one question.
Can i check a single node undetermined in JsTree depending on what
user enter in text box?

Eg can i do something like:
$.jstree._reference(#mytree).check_node("undetermined",41)


Where 41 is id of node and undetermined(one of the 3 state checked,
undetermined and unchecked) is state.

Thanks in advance for help.

mvwd

unread,
Jan 28, 2011, 12:06:37 PM1/28/11
to jsTree
For the checkboxes there are three methods to change the checked/
unchecked-state:

Check:
$.jstree._reference('#mytree').check_node('#id-of-node');
Uncheck:
$.jstree._reference('#mytree').uncheck_node('#id-of-node');
Toggle check:
$.jstree._reference('#mytree').change_state('#id-of-node');

The state "undetermined" is in my opinion only for showing that some
(not all) child-nodes of the node are checked. There's no method to
set it directly as "undetermined".
But if really needed, you can change the css-class to make it look as
"undetermined":

$('#id-of-node').removeClass('jstree-checked jstree-
unchecked').addClass('jstree-undetermined');

But this will NOT result in any changes about the 'state' of the node/
checkbox recognized by the checkbox-plugin!!

Markus.

Alkingson

unread,
Jan 31, 2011, 1:10:12 PM1/31/11
to jsTree
Thanks for your reply I got it working..One last question I am using
asp.net and have created a div with which I associate JSTree..What I
have to do to make sure that tree only loads if certain button is
clicked on page? Right now it looks for the div and loads
everytime..what I did is to provide wrong Ajax URL so tree wont load
and make it invisible..when user clicks on show tree button I provide
correct Ajax url and make tree visible true...But its ugly
workaround..I want to apply better soluation..Please help
Thanks,
Alkingson
> > Thanks in advance for help.- Hide quoted text -
>
> - Show quoted text -

mvwd

unread,
Feb 1, 2011, 2:59:10 AM2/1/11
to jsTree
It's just a bit jQuery-magic:

$('#id-of-button').click(function(){
if($.jstree._reference('#id-of-div')==null){
$('#id-of-div').jstree({ .... });
}
});

This piece of code reacts on click, checks if the tree is existing and
creates it if not.

Markus.
Reply all
Reply to author
Forward
0 new messages