Hi,
I am using WebDataGrid v11.2. I have a 2 level tree structure with checkboxes. I would like to change the behavior of the Parent checkbox.
Currently,the parent checkbox represents an all or none for the children. I would like to reverse the behavior as follows:
Currently, if the parent checkbox is checked all of the children are checked. I would like to change it to if one child is checked the parent is checked.
Currently, ff the parent is unchecked all of the children are unchecked. I would like to keep this behavior
Currrently, if all of the children are checked and you uncheck one child, the parent is unchecked. I would like to change it to if you uncheck a child and others are till checked, the parent remains checked.
Basically, I want the parent to represent at least one child is checked. Do I have to write events to do this or is it a configuration setting?
Thanks.
I figured out this problem also. Again, I set an attribute incorrectly. I changed the InitialDataBindDepth to '1' and now the code behind can identify the children of the parents.
Thanks for all your help.
I figured out my problem with the CheckBoxMode behavior. I needed to set the attributeEnableAutoCheckingtotrue. Now, it works as you described.
However, my problem setting the checkboxes in the code behind is still a problem. The data is displayed in a parent - children relationship but in the code behind none of the parents are identified as having children. the attribute HasChildren is false for all.
Thanks for replying.
I made the changes to the CheckBoxMode and the behavior is not as you describe. When I check one of the children of a parent the checkbox of the parent does not change. It does not change to a partial check. Do I have to add an event for the parent checkbox to update?
If I check the parent, none of the children are checked.
Secondly, I would like to initialize the checkboxes in the code behind. I can get the parent node to be checked but not the child node.
The parent nodes can be checked correctly. But the child nodes are never set.
node.Populatedis always false even though their are children.
node.Nodes is null. Shouldn't it represent all of the children of the parent, node?
This is my code:
protected void Page_Load(object sender, EventArgs e){ if (!Page.IsPostBack) { string key = Request.QueryString["ID"].ToString(); //Populate the DataTree using a DataSet this.DataTree1.DataSource = GetDataForMedGroupsWithLocations(); this.DataTree1.DataBind(); SetInitialOfficeSelections(key); }} protected void SetInitialOfficeSelections(string strDoctorID){ //This data table is populated with the offices that need to be checked. //Using a stored procedure not shown. It works. DataTable dtSelectedOffices = new DataTable("Offices"); //Check the locations for this doctor string tstrMedGroupID = String.Empty; string tstrOfficeID = String.Empty; bool tbChildNodeFound = false; foreach (DataRow row in dtSelectedOffices.Rows) { tstrMedGroupID = row["MedicalGroupID"].ToString(); tstrOfficeID = row["OfficeID"].ToString(); foreach (DataTreeNode node in DataTree1.Nodes) { if (node.Value.Equals(tstrMedGroupID)) {
//This checkbox is correctly set. This is the parent node node.CheckState = Infragistics.Web.UI.CheckBoxState.Checked; break;//node.Populated is always false even though their are children in the parent node.
//The child checkboxes are never set.
//How do you access the child nodes to check the checkboxes of the children?
if (node.Populated) { foreach (DataTreeNode childNode in node.Nodes) { if (childNode.Value.Equals(tstrOfficeID)) { childNode.CheckState = Infragistics.Web.UI.CheckBoxState.Checked; tbChildNodeFound = true; break; } //end childNode if } //end for loop offices - child node } //end populated if if (tbChildNodeFound) { tbChildNodeFound = false; break; } } //end med group if } //end for loop med group - parent node }}
Hello Gloria,
Thank you for posting in our community!
It seems you are currently ussing CheckBoxMode="BiState"I believe what you describe as wanted behavior is actually the behavior available if CheckBoxMode="TriState" is set. What is required is to change this property and the changes will be automatically applied.
You could refer to the following resources as well: Using CheckBoxes in WebDataTreeCheckBoxMode Enumeration