Treeview复选框 - 如果选中子项,则选中/取消选中父节点 [英] Treeview checkbox - check/uncheck parent nodes if child is checked

查看:103
本文介绍了Treeview复选框 - 如果选中子项,则选中/取消选中父节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用Treeview与 ShowCheckBoxes =All,所以基本上我有一个包含所有CheckBox节点的树。我正在使用TreeView动态填充Tree代码。



我的要求如下:



1)如果选择任何子节点,则检查所有父节点。喜欢从低到高检查



Hi,

I'm using a Treeview with ShowCheckBoxes="All" , so basically I have a tree with all CheckBox Nodes. I'm using the TreeView populate the Tree code behind dynamically.

My requrements are the following:

1) If Select Any Child Node then checked all parent nodes. like lower to upper checked

ex :- Treeview Exmp-
         >>  India 
                   >>New Delhi
                   >>Chandigarh
                   >>Bangalore
                   >>KolKata



如果我选择班加罗尔后自动选中 Chandigarg 新德里父节点印度。 Jquery,JavaScript,Server Side使用的任何东西



任何人都可以帮助我..

提前致谢...



我尝试过:




if i select Bangalore after automatically checked Chandigarg, New Delhi And parent node India. Jquery,JavaScript,Server Side anything used

Can anyone help me..
Thanks in advance...

What I have tried:

$(document).ready(function () {

            $("#<%= TreeView1.ClientID %>").find("input").click(function () {

                

                    var parentChk = $("#" + $(this).parents(":eq(4)").attr("id").replace('Nodes', 'CheckBox'));
                    debugger;
                    var allChecked = true;
                    var allUnchecked = true;

                    $(this).parents(":eq(4)").find("input").each(function () {

                        if ($(this).attr("checked")) {

                            allUnchecked = false;
                        }
                        else {
                            allChecked = false;
                            parentChk.attr("checked", true);
                        }
                    });

                    if (allChecked) {
                        parentChk.attr("checked", true);
                    }
                    else if (allUnchecked) {
                        parentChk.attr("checked", false);
                    }
            });
        });

推荐答案

document )。ready ( function (){
(document).ready(function () {


#& lt;%= TreeView1.ClientID%>)。find( 输入)。单击( function (){



var parentChk =
("#<%= TreeView1.ClientID %>").find("input").click(function () { var parentChk =


+


这篇关于Treeview复选框 - 如果选中子项,则选中/取消选中父节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆