프론트엔드 코드 코드 복사 코드는 다음과 같습니다. <br>//클라이언트 캡처 이벤트<br>function CheckEvent() { <br>var objNode = event.srcElement; <br>if (objNode.tagName == "INPUT" && objNode.type == "checkbox ") { <br>var objParentDiv = objNode.id.replace("CheckBox", "Nodes"); <br>if (objNode.checked == true) { <br>setChildCheckState(objParentDiv, true); 🎜> setParentCheckeState(objNode, true); <br>} <br>else { <br>setChildCheckState(objParentDiv, false) <br>if (!HasOtherChecked(objNode)) { <br>setParentCheckeState(objNode, false); <br>} <br>} <br>} <br>} <br>//다른 병렬 노드가 선택되었는지 확인<br>function HasOtherChecked(objNode) { <br>var objParentDiv = WebForm_GetParentByTagName(objNode, "div" ); <br>var chks = objParentDiv.getElementsByTagName("INPUT"); <br>for (var i = 0; i < chks.length; i ) { <BR>if (chks[i].checked && chks [i].id != objNode.id) { <BR>return true; <BR>} <BR>} <BR>return false <BR>} <BR>//상위 노드 설정<BR>function setParentCheckeState ( objNode, chkstate) { <BR>try { <BR>var objParentDiv = WebForm_GetParentByTagName(objNode, "div"); <BR>if (objParentDiv == null || objParentDiv == "undefine ") { <BR>return; <BR>} <BR>else { <BR>var objParentChkId = objParentDiv.id.replace("Nodes", "CheckBox"); <BR>var objParentCheckBox = document.getElementById(objParentChkId) <BR>if (objParentCheckBox) { <BR>objParentCheckBox.checked = chkstate; <BR>setParentCheckeState(objParentDiv, chkstate); <BR>} <BR>} <BR>} <BR>catch (e) { } <BR>} <BR>// 하위 노드 설정 <BR>function setChildCheckState(nodeid, chkstate) { <BR>var node = document.getElementById(nodeid); <BR>if (node) { <BR>var chks = node.getElementsByTagName("INPUT"); <BR>for (var i = 0; i < chks.length; i ) { <BR>chks[i].checked = chkstate; <BR>} <BR>} <BR>} <BR></ 스크립트> <br><body> <br><form id="form1" runat="server"> <br><asp:TreeView ID="TreeView1" runat="server" ShowCheckBoxes="All" onclick ="CheckEvent()"> <br></form> <br><br> <br>백엔드 코드: <br> </div> <br><br><div class="codetitle">코드 복사<span><a style="CURSOR: pointer" data="71468" class="copybut" id="copybut71468" onclick="doCopy('code71468')"><u> 코드는 다음과 같습니다.</u></a> </span>private void BindGrid() </div>{ <div class="codebody" id="code71468"> DataTable mytable = menuTableBll .GetAllList().Tables[0]; //데이터 가져오기<br>CreateTree(mytable, TreeView1.Nodes, "0") <br>} <br>private void CreateTree(DataTable dtNodeSets, TreeNodeCollection node , string parent_id) <br>{ <br>DataView dvList = new DataView(dtNodeSets); <br>dvList.RowFilter = "MeunParentId =" parent_id; <br>TreeNode nodeTemp <br>foreach(dvList의 DataRowView dv) 🎜>{ <br>nodeTemp = new TreeNode(); <br>nodeTemp.Text = dv["MenuName"].ToString(); <br>nodeTemp.Expanded = <br>nodeTemp.ToolTip = dv[" MeunId"].ToString(); <br>node.Add(nodeTemp); <br>CreateTree(dtNodeSets, nodeTemp.ChildNodes, dv["MeunId"].ToString()); <br>} <br>} <br><br> </div>