As of JSTree version 3.1.1 here is what I would do:
$('#data').jstree({
'core' : {
'data' : [
{ "text" : "Root node", "children" : [
{ "text" : "Child node 1" },
{ "text" : "Child node 2" }
]},
{ "text" : "Root node 2", "children" : [
{ "text" : "Child node 1" },
]}
]
},
'checkbox': {
three_state: false,
cascade: 'up'
},
'plugins': ["checkbox"]
});
JSFiddle Demo
Note that the magic here happens with the checkbox parameters.
From the documentation:
three_state: a boolean indicating if checkboxes should cascade down
and have an undetermined state. Defaults to true
.
cascade: This setting controls how cascading and undetermined nodes
are applied. If 'up' is in the string - cascading up is enabled, if
'down' is in the string - cascading down is enabled, if 'undetermined'
is in the string - undetermined nodes will be used. If three_state
is set to true
this setting is automatically set to
'up+down+undetermined'. Defaults to ''.
This documentation was found inside of the source code for v.3.1.1
EDIT I just checked v3.3.0, and although the documentation changed for these attributes (in my opinion, for the worse), the code works just the same. In the meantime though it looks like these attributes are listed in their API: three_state and cascade and as of writing this seem to have better documentation than the source code.
Keep in mind that if you have multiple child nodes underneath a parent, checking just one of the children will not check the parent. All nodes must be checked to take effect on the parent.
Hope this helps!