Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 06, 2009 12:06 AM by hapytran
Member
82 Points
41 Posts
Sep 05, 2009 03:32 AM|LINK
Hi All,
I have a treeview like this:
[-] Node1 [] Child1 [] Child2 [] Child3 [] Child4 [-] Node2 [] Child1 [-] Node3 [-] Child1 [] Childx [] Childy [+] Child2 [-] Node4 [-] Child1 [-] Child2 [+] Child3 [] Child4 [] Child5 [] Child6 [] Child7
At time, Can we force user works only on one branch of tree. For example, if user check one child of "Node1" (or multi), uncheck all child nodes of "Node2", "Node3", "Node4". Apply same for Node2, Node3, ...
Thanks for help.
Eric.
Sep 06, 2009 12:06 AM|LINK
It seems that we can not do it at client side. Below is code at server side:
protected void TreeNodeCheckChanged(object sender, TreeNodeEventArgs e) { string[] path = e.Node.ValuePath.Split('/'); //collapse other nodes foreach (TreeNode node in trvTargetMarket.Nodes) { if (node.Value != path[0]) { UnSelectedNodes(node.ChildNodes); //node.Collapse(); } } } protected void UnSelectedNodes(TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { if (node.Checked) { node.Checked = false; } if (node.ChildNodes.Count > 0) UnSelectedNodes(node.ChildNodes); } }
hapytran
Member
82 Points
41 Posts
User can only select child of branch at time - treeview
Sep 05, 2009 03:32 AM|LINK
Hi All,
I have a treeview like this:
[-] Node1
[] Child1
[] Child2
[] Child3
[] Child4
[-] Node2
[] Child1
[-] Node3
[-] Child1
[] Childx
[] Childy
[+] Child2
[-] Node4
[-] Child1
[-] Child2
[+] Child3
[] Child4
[] Child5
[] Child6
[] Child7
At time, Can we force user works only on one branch of tree. For example, if user check one child of "Node1" (or multi), uncheck all child nodes of "Node2", "Node3", "Node4". Apply same for Node2, Node3, ...
Thanks for help.
Eric.
hapytran
Member
82 Points
41 Posts
Re: User can only select child of branch at time - treeview
Sep 06, 2009 12:06 AM|LINK
It seems that we can not do it at client side. Below is code at server side:
protected void TreeNodeCheckChanged(object sender, TreeNodeEventArgs e) { string[] path = e.Node.ValuePath.Split('/'); //collapse other nodes foreach (TreeNode node in trvTargetMarket.Nodes) { if (node.Value != path[0]) { UnSelectedNodes(node.ChildNodes); //node.Collapse(); } } } protected void UnSelectedNodes(TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { if (node.Checked) { node.Checked = false; } if (node.ChildNodes.Count > 0) UnSelectedNodes(node.ChildNodes); } }