问题
I have a treeview, I want to check all the children when I clicked the parent node from javascript. I have followed this link from stackoverflow. This process is currect. I have tested it with alert message also.
The ID which is showing in the alert message is exactly right ID of the child. And the method is been setting the status also. Code is reaching herechildChkBoxes[i].checked = check;
function CheckUncheckChildren(childContainer, check) {
var childChkBoxes = childContainer.getElementsByTagName("input");
var childChkBoxCount = childChkBoxes.length;
for (var i = 0; i < childChkBoxCount; i++) {
alert("Childer lenght = "+childChkBoxes.length +" childern ID "+ childChkBoxes[i].id + " Parent checked state =" + check);
childChkBoxes[i].checked = check;
}
}
even the check box of child is not been checking in UI. What might be the problem. This code is working for every one. Why not working here, I am displaying the treeview in a modelpopupextender control. Is anything wrong with my browser, I am using firefox. Is anything wrong with my treeview design. her it is
<asp:TreeView ID="tvFolderSelect" runat="server" RootNodeStyle-ForeColor="Black"
CssClass="foldertree" LeafNodeStyle-ForeColor="Black" LeafNodeStyle-Font-Bold="false"
ParentNodeStyle-ForeColor="Black" Width="100%" Style="margin: 3px 0 0 -16px;"
OnTreeNodePopulate="tvFolderSelect_TreeNodePopulate" onclick="OnTreeClick(event);"
ShowCheckBoxes="All" >
<LeafNodeStyle Font-Bold="False" ForeColor="Black" CssClass="foldertreeleafnode"
ImageUrl="~/images/img_dms/sm_fldr.png" />
<ParentNodeStyle Font-Italic="True" ImageUrl="~/images/img_dms/sm_fldr.png" Font-Underline="True"
CssClass="foldertreeparentnode"/>
<NodeStyle Font-Names="Tahoma" Font-Size="8pt" ForeColor="Black" HorizontalPadding="0px"
NodeSpacing="0px" VerticalPadding="0px" />
<RootNodeStyle ForeColor="Black" CssClass="foldertreerootnode" />
<SelectedNodeStyle Font-Underline="False" HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>
I tried this code in normal aspx page(not in modelpopupextender). And it is working well
来源:https://stackoverflow.com/questions/21985699/checked-property-not-working-in-treeview-checkboxes