Home > Web Front-end > JS Tutorial > body text

Jstree solution for disabled child nodes to be selected when the parent node is selected

小云云
Release: 2017-12-27 13:46:03
Original
2716 people have browsed it

This article mainly shares with you an article to solve the problem that disabled child nodes are also selected when the parent node is selected in Jstree. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor to take a look, I hope it can help everyone.

Problem description:

I recently encountered a problem using jstree. When the parent node is selected, the disabled child nodes will also be selected as follows

Solution:

1. Upgrade jstree to the latest version, v3.3.4 and above You can

2. Modify the checkbox plug-in configuration and set cascade_to_disabled to false (note: the configuration script needs to be placed after jstree.min.js)


<script src="./../../dist/jstree.min.js"></script>
<script>
$.jstree.defaults.checkbox = {
      visible: true,
      three_state: true,
      whole_node: true,
      keep_selected_style: true,
      cascade: &#39;&#39;,
      tie_selection: true,
      /**
      * This setting controls if cascading down affects disabled checkboxes
      * @name $.jstree.defaults.checkbox.cascade_to_disabled
      * @plugin checkbox
      */
      cascade_to_disabled : false,
      cascade_to_hidden : true
};
 
 
$(&#39;#data&#39;).jstree({
    &#39;core&#39; : {
      &#39;data&#39; : [
        { "text" : "Root node", "children" : [
            { "text" : "Child node 1", "state": { "disabled": true } },
            { "text" : "Child node 2" },
            { "text" : "Child node 3" },
            { "text" : "Child node 4" },
            { "text" : "Child node 5" },
            { "text" : "Child node 6" }
        ]}
      ]
    }
    ,"plugins" : [ "checkbox" ]
  });
</script>
Copy after login


After modification, when the parent node is selected, the child node will skip the disabled child node as follows:

Related recommendations:

Tutorial examples on how to implement the jstree radio selection function

javascript - Laravel generates json data of jstree

jquery.jstree Add the double-click event code of the node_jquery

The above is the detailed content of Jstree solution for disabled child nodes to be selected when the parent node is selected. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!