Completed
Last Updated: 09 Feb 2017 11:29 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 17 Jan 2017 07:57
Category: TreeView
Type: Bug Report
1
FIX. RadTreeView - incorrect CheckState for the parent nodes
To reproduce:

this.radTreeView1.TriStateMode = true;

RadTreeNode sitesNode = radTreeView1.Nodes.Add("Sites", "Sites", "");
sitesNode.Expanded = true;

RadTreeNode siteNode = new RadTreeNode("A site");
sitesNode.Nodes.Add(siteNode);

RadTreeNode eNode = new RadTreeNode("Event Types");
siteNode.Nodes.Add(eNode);
siteNode.Expanded = true;
RadTreeNode dummy = new RadTreeNode("dummy");
eNode.Nodes.Add(dummy);
dummy.CheckState = ToggleState.On;

RadTreeNode dummy2 = new RadTreeNode("dummy2");
eNode.Nodes.Add(dummy2);
dummy2.CheckState = ToggleState.Off;

Please refer to the attached screenshot. 

Workaround: change the CheckState property after all nodes are added to RadTreeView.

this.radTreeView1.TriStateMode = true;

RadTreeNode sitesNode = radTreeView1.Nodes.Add("Sites", "Sites", "");
sitesNode.Expanded = true;

RadTreeNode siteNode = new RadTreeNode("A site");
sitesNode.Nodes.Add(siteNode);

RadTreeNode eNode = new RadTreeNode("Event Types");
siteNode.Nodes.Add(eNode);
siteNode.Expanded = true;
RadTreeNode dummy = new RadTreeNode("dummy");
eNode.Nodes.Add(dummy);


RadTreeNode dummy2 = new RadTreeNode("dummy2");
eNode.Nodes.Add(dummy2);

dummy2.CheckState = ToggleState.Off; 
dummy.CheckState = ToggleState.On;
Attached Files:
2 comments
ADMIN
Stefan
Posted on: 06 Feb 2017 11:36
Thank you for your input Lou and for reporting this.
Lou
Posted on: 17 Jan 2017 16:43
As the person who found this issue I wanted to say that it's quite painful to workaround the issue as suggested. It's best to set the checkbox state of a node right next to where that node is created if possible. The workaround forces me to store a list of all of the nodes and their states, and then at the end I have to loop over all of the nodes and set the states. This is more coding (code becomes more confusing) and takes more resources. This seems like a pretty bad bug - when I ran into the problem I thought it must be my code going wrong, not a basic logic issue with the control. So it cost me quite a bit of time and frustration trying to figure out where my code was going wrong when actually the treeview checkbox states weren't working properly. Fixing this bug will save other people from these issues. Hopefully it won't be a difficult fix. Thanks !