gpt4 book ai didi

javascript - 在 TreeView 中选择父节点时如何选择所有子节点? (当从用户控件使用 TreeView 时)

转载 作者:行者123 更新时间:2023-11-28 02:13:46 26 4
gpt4 key购买 nike

我有一个只有 Treeview 控件的用户控件。

<asp:TreeView ID="Tree_Index" 
Style="font-size: 11px; font-family: Tahoma; font-weight: bold; text-align: left;" runat="server" Width="10px"
EnableClientScript="False" ShowCheckBoxes="All" ShowLines="True">
</asp:TreeView>

在我的 aspx 页面中,我多次使用此用户控件,以便在我的 aspx 页面中显示具有不同数据的多个 TreeView 。

我像下面这样调用用户控件

Public Sub PopulateTreeview() 
Dim cph As ContentPlaceHolder = CType(Me.Master.FindControl("cphMain"), ContentPlaceHolder)
Dim Treeview_Control As Controls_Deot_treecontrol

Dim ds As DataSet = SPServiceModel.GetAllServiceCategorizationTypes()
Dim dtRight As DataTable = ds.Tables(0)

For i As Integer = 0 To dtRight.Rows.Count - 1
Treeview_Control = CType(LoadControl("Deot/treecontrol.ascx"), Controls_Deot_treecontrol)
Treeview_Control.ID = "Treecontrol_Right_" + i.ToString()
Treeview_Control.SetCategoryID(dtRight.Rows(i)("id").ToString())
cph.FindControl("pnl_right").Controls.Add(Treeview_Control)
Next
End Sub

假设我的 aspx 页面上有 6 个 TreeView 。我想在选择父节点时选择父节点的所有子节点。 TreeView 将具有三层节点。因此,应该为该特定树选择父节点内的所有节点。

我该如何实现这一点,因为ID是我在aspx页面中设置的。我如何使用 javascript 或 jquery 或用户控件的代码隐藏来实现此目的?

渲染的 HTML:

<div id="ctl00_cphMain_pnl_left">



<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("div[id $= Tree_Index] input[type=checkbox]").click(function () {
$(this).closest("table").next("div").find("input[type=checkbox]").attr("checked", this.checked);
});
});
</script>


<a href="#ctl00_cphMain_ctl03_Tree_Index_SkipLink"><img width="0" height="0" style="border-width:0px;" src="/WebResource.axd?d=vp_dPIRRqCpyFrxPBwqvPmsO-wa56CpxZGlT_T-AdX5QN0qJOs_wgfq4QMJwRILSj9XSONYmkJAe85CVEph0Q1SfUqs1&amp;t=634604712479085897" alt="Skip Navigation Links."></a><div style="width:10px;font-size: 11px; font-family: Tahoma; font-weight: bold; text-align: left;" onclick="OnTreeClick(event)" id="ctl00_cphMain_ctl03_Tree_Index">
<table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><a href="javascript:__doPostBack('ctl00$cphMain$ctl03$Tree_Index','t1730b784-94ca-42d3-80aa-1c9c064e271c')"><img style="border-width:0;" alt="Collapse Clinics" src="/WebResource.axd?d=_533LbcrYzxclETTqT9E9lbjpoP9iiSVLn9WP908dD96sH9D2JXH4BN8Q2OdATM4TYJU67kfDSnJQpffp_ITMVu3Y839pir-IzEhB41mqu6U8EWb0&amp;t=634604712479085897"></a></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl03_Tree_Indexn0CheckBox" name="ctl00_cphMain_ctl03_Tree_Indexn0CheckBox"><a id="ctl00_cphMain_ctl03_Tree_Indext0" href="javascript:__doPostBack('ctl00$cphMain$ctl03$Tree_Index','s1730b784-94ca-42d3-80aa-1c9c064e271c')" class="ctl00_cphMain_ctl03_Tree_Index_0">Clinics</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl03_Tree_Indexn1CheckBox" name="ctl00_cphMain_ctl03_Tree_Indexn1CheckBox"><a id="ctl00_cphMain_ctl03_Tree_Indext1" href="javascript:__doPostBack('ctl00$cphMain$ctl03$Tree_Index','s1730b784-94ca-42d3-80aa-1c9c064e271c\\8086a7e5-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl03_Tree_Index_0">Respite Care Services</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl03_Tree_Indexn2CheckBox" name="ctl00_cphMain_ctl03_Tree_Indexn2CheckBox"><a id="ctl00_cphMain_ctl03_Tree_Indext2" href="javascript:__doPostBack('ctl00$cphMain$ctl03$Tree_Index','s1730b784-94ca-42d3-80aa-1c9c064e271c\\5586a7e5-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl03_Tree_Index_0">Caregiver Training</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl03_Tree_Indexn3CheckBox" name="ctl00_cphMain_ctl03_Tree_Indexn3CheckBox"><a id="ctl00_cphMain_ctl03_Tree_Indext3" href="javascript:__doPostBack('ctl00$cphMain$ctl03$Tree_Index','s1730b784-94ca-42d3-80aa-1c9c064e271c\\643eafdf-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl03_Tree_Index_0">Psychiatric Rehabilitation Homes</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl03_Tree_Indexn4CheckBox" name="ctl00_cphMain_ctl03_Tree_Indexn4CheckBox"><a id="ctl00_cphMain_ctl03_Tree_Indext4" href="javascript:__doPostBack('ctl00$cphMain$ctl03$Tree_Index','s1730b784-94ca-42d3-80aa-1c9c064e271c\\613dafdf-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl03_Tree_Index_0">Befriending Service</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl03_Tree_Indexn5CheckBox" name="ctl00_cphMain_ctl03_Tree_Indexn5CheckBox"><a id="ctl00_cphMain_ctl03_Tree_Indext5" href="javascript:__doPostBack('ctl00$cphMain$ctl03$Tree_Index','s1730b784-94ca-42d3-80aa-1c9c064e271c\\6fe899f7-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl03_Tree_Index_0">Polyclinics</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl03_Tree_Indexn6CheckBox" name="ctl00_cphMain_ctl03_Tree_Indexn6CheckBox"><a id="ctl00_cphMain_ctl03_Tree_Indext6" href="javascript:__doPostBack('ctl00$cphMain$ctl03$Tree_Index','s1730b784-94ca-42d3-80aa-1c9c064e271c\\7393b4d9-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl03_Tree_Index_0">Caregiver Support Service</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=BOvsSO2B3BKMupOSRxbma89ER-i_r1FrqfnVsgVq_QiVog3IJUebdD29i4BVAo26-lbJh_BLXmsQGU_VArXhNt6ejiWJk87whzKer6ts-_kM9Vt90&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl03_Tree_Indexn7CheckBox" name="ctl00_cphMain_ctl03_Tree_Indexn7CheckBox"><a id="ctl00_cphMain_ctl03_Tree_Indext7" href="javascript:__doPostBack('ctl00$cphMain$ctl03$Tree_Index','s1730b784-94ca-42d3-80aa-1c9c064e271c\\7a93b4d9-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl03_Tree_Index_0">Helpline - Caregiver Helpline</a></td>
</tr>
</tbody></table>
</div><a id="ctl00_cphMain_ctl03_Tree_Index_SkipLink"></a>
<br>



<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("div[id $= Tree_Index] input[type=checkbox]").click(function () {
$(this).closest("table").next("div").find("input[type=checkbox]").attr("checked", this.checked);
});
});
</script>


<a href="#ctl00_cphMain_ctl04_Tree_Index_SkipLink"><img width="0" height="0" style="border-width:0px;" src="/WebResource.axd?d=vp_dPIRRqCpyFrxPBwqvPmsO-wa56CpxZGlT_T-AdX5QN0qJOs_wgfq4QMJwRILSj9XSONYmkJAe85CVEph0Q1SfUqs1&amp;t=634604712479085897" alt="Skip Navigation Links."></a><div style="width:10px;font-size: 11px; font-family: Tahoma; font-weight: bold; text-align: left;" onclick="OnTreeClick(event)" id="ctl00_cphMain_ctl04_Tree_Index">
<table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><a href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','tace7ae2e-c160-4982-a90f-785fc5b7cca7')"><img style="border-width:0;" alt="Collapse Home Care" src="/WebResource.axd?d=_533LbcrYzxclETTqT9E9lbjpoP9iiSVLn9WP908dD96sH9D2JXH4BN8Q2OdATM4TYJU67kfDSnJQpffp_ITMVu3Y839pir-IzEhB41mqu6U8EWb0&amp;t=634604712479085897"></a></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn0CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn0CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext0" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7')" class="ctl00_cphMain_ctl04_Tree_Index_0">Home Care</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><a href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','tace7ae2e-c160-4982-a90f-785fc5b7cca7\\0f93b4d9-217e-e111-9ca9-005056ba0039')"><img style="border-width:0;" alt="Collapse Home Nursing" src="/WebResource.axd?d=PtoZaOE4OJ68kA17eB1Ru-nLDbZ-ilvB8z5abVJ8BfKZp0iKKZ8iPpsV8tJ5bLWmNAAyfP3gCpxQRyrUtuHqeJKGILYd8Nbb3deoYK17HD9ZYyeS0&amp;t=634604712479085897"></a></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn1CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn1CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext1" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\0f93b4d9-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Home Nursing</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><div style="width:20px;height:1px"><img alt="" src="/WebResource.axd?d=J9BSVEmYJ2R79DzKPp_KwudhxkmRYjt31taLGpqjHFuG3gyciimdNIz2hfef3rMTcgKKF9rZcFetwoS-fvXnw3uYWh88CZ98-dNXPYEoMwTaffwZ0&amp;t=634604712479085897"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn2CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn2CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext2" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\0f93b4d9-217e-e111-9ca9-005056ba0039\\00000000-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Third Level 1</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><div style="width:20px;height:1px"><img alt="" src="/WebResource.axd?d=J9BSVEmYJ2R79DzKPp_KwudhxkmRYjt31taLGpqjHFuG3gyciimdNIz2hfef3rMTcgKKF9rZcFetwoS-fvXnw3uYWh88CZ98-dNXPYEoMwTaffwZ0&amp;t=634604712479085897"></div></td><td><img alt="" src="/WebResource.axd?d=BOvsSO2B3BKMupOSRxbma89ER-i_r1FrqfnVsgVq_QiVog3IJUebdD29i4BVAo26-lbJh_BLXmsQGU_VArXhNt6ejiWJk87whzKer6ts-_kM9Vt90&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn3CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn3CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext3" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\0f93b4d9-217e-e111-9ca9-005056ba0039\\11111111-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Third Level 2</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn4CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn4CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext4" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\c13eafdf-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Private Nursing Homes</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn5CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn5CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext5" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\1493a4eb-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Personal Healthcare Assistant</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn6CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn6CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext6" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\f592b4d9-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Home Medical</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn7CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn7CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext7" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\2493b4d9-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Home Therapy - Physiotherapy</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn8CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn8CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext8" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\1a93b4d9-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Home Therapy - Occupational Therapy</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn9CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn9CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext9" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\083eafdf-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Social Day Care Services</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn10CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn10CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext10" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\e7ba9bfd-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Community VWO Clinics</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn11CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn11CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext11" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\b292b4d9-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Day Rehabilitation Services</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn12CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn12CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext12" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\2087a7e5-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Community Wellness Clubs</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=BOvsSO2B3BKMupOSRxbma89ER-i_r1FrqfnVsgVq_QiVog3IJUebdD29i4BVAo26-lbJh_BLXmsQGU_VArXhNt6ejiWJk87whzKer6ts-_kM9Vt90&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl04_Tree_Indexn13CheckBox" name="ctl00_cphMain_ctl04_Tree_Indexn13CheckBox"><a id="ctl00_cphMain_ctl04_Tree_Indext13" href="javascript:__doPostBack('ctl00$cphMain$ctl04$Tree_Index','sace7ae2e-c160-4982-a90f-785fc5b7cca7\\8f93b4d9-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl04_Tree_Index_0">Community Hospitals</a></td>
</tr>
</tbody></table>
</div><a id="ctl00_cphMain_ctl04_Tree_Index_SkipLink"></a>
<br>



<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("div[id $= Tree_Index] input[type=checkbox]").click(function () {
$(this).closest("table").next("div").find("input[type=checkbox]").attr("checked", this.checked);
});
});
</script>


<a href="#ctl00_cphMain_ctl05_Tree_Index_SkipLink"><img width="0" height="0" style="border-width:0px;" src="/WebResource.axd?d=vp_dPIRRqCpyFrxPBwqvPmsO-wa56CpxZGlT_T-AdX5QN0qJOs_wgfq4QMJwRILSj9XSONYmkJAe85CVEph0Q1SfUqs1&amp;t=634604712479085897" alt="Skip Navigation Links."></a><div style="width:10px;font-size: 11px; font-family: Tahoma; font-weight: bold; text-align: left;" onclick="OnTreeClick(event)" id="ctl00_cphMain_ctl05_Tree_Index">
<table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><a href="javascript:__doPostBack('ctl00$cphMain$ctl05$Tree_Index','tfc052442-3b20-4cdc-8d20-9c8544ac1c6f')"><img style="border-width:0;" alt="Collapse Other Services" src="/WebResource.axd?d=_533LbcrYzxclETTqT9E9lbjpoP9iiSVLn9WP908dD96sH9D2JXH4BN8Q2OdATM4TYJU67kfDSnJQpffp_ITMVu3Y839pir-IzEhB41mqu6U8EWb0&amp;t=634604712479085897"></a></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl05_Tree_Indexn0CheckBox" name="ctl00_cphMain_ctl05_Tree_Indexn0CheckBox"><a id="ctl00_cphMain_ctl05_Tree_Indext0" href="javascript:__doPostBack('ctl00$cphMain$ctl05$Tree_Index','sfc052442-3b20-4cdc-8d20-9c8544ac1c6f')" class="ctl00_cphMain_ctl05_Tree_Index_0">Other Services</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl05_Tree_Indexn1CheckBox" name="ctl00_cphMain_ctl05_Tree_Indexn1CheckBox"><a id="ctl00_cphMain_ctl05_Tree_Indext1" href="javascript:__doPostBack('ctl00$cphMain$ctl05$Tree_Index','sfc052442-3b20-4cdc-8d20-9c8544ac1c6f\\45bb0a98-ec44-e211-beaf-005056ba0039')" class="ctl00_cphMain_ctl05_Tree_Index_0">Mobile Services</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl05_Tree_Indexn2CheckBox" name="ctl00_cphMain_ctl05_Tree_Indexn2CheckBox"><a id="ctl00_cphMain_ctl05_Tree_Indext2" href="javascript:__doPostBack('ctl00$cphMain$ctl05$Tree_Index','sfc052442-3b20-4cdc-8d20-9c8544ac1c6f\\9b3dafdf-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl05_Tree_Index_0">Hospice Day Care</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl05_Tree_Indexn3CheckBox" name="ctl00_cphMain_ctl05_Tree_Indexn3CheckBox"><a id="ctl00_cphMain_ctl05_Tree_Indext3" href="javascript:__doPostBack('ctl00$cphMain$ctl05$Tree_Index','sfc052442-3b20-4cdc-8d20-9c8544ac1c6f\\f83dafdf-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl05_Tree_Index_0">Website - Disability Information Website</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=Ptpr_s5NKQd2NhXQH_MiSClxDVR5ZHar9QZwFenhB3L_8-vIXRA_NHlxqP3iWPQWzSbDizVZ5YO8o3q4fX1XUhismQEMBdpf8AuHvaSyrvYco4WB0&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl05_Tree_Indexn4CheckBox" name="ctl00_cphMain_ctl05_Tree_Indexn4CheckBox"><a id="ctl00_cphMain_ctl05_Tree_Indext4" href="javascript:__doPostBack('ctl00$cphMain$ctl05$Tree_Index','sfc052442-3b20-4cdc-8d20-9c8544ac1c6f\\33333333-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl05_Tree_Index_0">Information &amp; Referral Services</a></td>
</tr>
</tbody></table><table cellspacing="0" cellpadding="0" style="border-width:0;">
<tbody><tr>
<td><div style="width:20px;height:1px"></div></td><td><img alt="" src="/WebResource.axd?d=BOvsSO2B3BKMupOSRxbma89ER-i_r1FrqfnVsgVq_QiVog3IJUebdD29i4BVAo26-lbJh_BLXmsQGU_VArXhNt6ejiWJk87whzKer6ts-_kM9Vt90&amp;t=634604712479085897"></td><td style="white-space:nowrap;"><input type="checkbox" id="ctl00_cphMain_ctl05_Tree_Indexn5CheckBox" name="ctl00_cphMain_ctl05_Tree_Indexn5CheckBox"><a id="ctl00_cphMain_ctl05_Tree_Indext5" href="javascript:__doPostBack('ctl00$cphMain$ctl05$Tree_Index','sfc052442-3b20-4cdc-8d20-9c8544ac1c6f\\44444444-217e-e111-9ca9-005056ba0039')" class="ctl00_cphMain_ctl05_Tree_Index_0">Ambulance Service (Non-Emergency)</a></td>
</tr>
</tbody></table>
</div><a id="ctl00_cphMain_ctl05_Tree_Index_SkipLink"></a>
<br>


</div>

最佳答案

您可以简单地使用此代码

$(document).ready(function() {
$("div[id $= Tree_Index]").find("input[type=checkbox]:first").click(function() {
$(this).closest("div").find(':checkbox').attr('checked', this.checked);
});
});

js fiddle link is here

关于javascript - 在 TreeView 中选择父节点时如何选择所有子节点? (当从用户控件使用 TreeView 时),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16706482/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com