ztree control whether cascade selection

There is such a requirement that when selecting a tree, a check box needs to be used to control whether to cascade the selection, as shown in the figure below

                      

This horrible thing makes my heart tired, so I won’t mention the failed plan, just write the one that succeeded.

1: To write a zTreeBeforeCheck method

2: The alongCheck here is the id of the checkbox that is cascaded to select

        function zTreeBeforeCheck(treeId, treeNode) {
            //如果不是级联操作的话
            var input=$("#alongCheck");
            if(!$(input).is(':checked')){
                if (treeNode.checked) {
                    treeObj.checkNode(treeNode,false,false,false);
                }else{
                    treeObj.checkNode(treeNode,true,false,false);
                }
                return false;
            }else{
                return true;
            }
        };

 

 

At this point, many of the test failure schemes in the middle are actually quite meaningful. Many online answers about whether to cascade are very basic, just stay at the setting level. If you have any questions, leave a message. I am tired and don't want to give examples one by one. Failed plan

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_20594019/article/details/100700040