kris860911
Top achievements
Rank 1
kris860911
asked on 27 Mar 2008, 09:53 AM
Hi,
I am binding a treeview to a datatable.
The treeview has self-referencing data. And it loads correctly and shows correctly.
The problem I am having is this. Once the data is reloaded, I want to select the node that was selected already. So I need to use the Find method and make the node selected,
However, I read that the Find Method uses the Name Property to match the search term, but it seems like the Name Property is not populated when bound to a datasource.
Do you suggest a way to overcome this problem?
Thanks,
Kris
I am binding a treeview to a datatable.
The treeview has self-referencing data. And it loads correctly and shows correctly.
The problem I am having is this. Once the data is reloaded, I want to select the node that was selected already. So I need to use the Find method and make the node selected,
However, I read that the Find Method uses the Name Property to match the search term, but it seems like the Name Property is not populated when bound to a datasource.
Do you suggest a way to overcome this problem?
Thanks,
Kris
4 Answers, 1 is accepted
0
Accepted
Hi kris860911,
You can search by two different RadTreeView properties when you bind to a DataSource. The first one is the Text property, which is popluated as a DisplayMember and the second one is the Tag property which is populated as a ValueMember.
Currently, RadTreeView does not implement the FindNodeByText method, so please refer to the implementation below:
I hope this helps. If you have additional questions, do not hesitate to contact me.
Best wishes,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
You can search by two different RadTreeView properties when you bind to a DataSource. The first one is the Text property, which is popluated as a DisplayMember and the second one is the Tag property which is populated as a ValueMember.
Currently, RadTreeView does not implement the FindNodeByText method, so please refer to the implementation below:
RadTreeNode FindNodeByText(RadTreeNodeCollection nodeCollection, string text) |
{ |
foreach (RadTreeNode node in nodeCollection) |
{ |
if ((node.Text == text) && (node != this.radTreeView1.SelectedNode)) |
{ |
return node; |
} |
RadTreeNode result = this.FindNodeByText(node.Nodes, text); |
if (result != null) |
{ |
return result; |
} |
} |
return null; |
} |
I hope this helps. If you have additional questions, do not hesitate to contact me.
Best wishes,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
TECH GURU
Top achievements
Rank 1
answered on 16 Sep 2009, 10:16 PM
I found this after I posted my query. I have a question regarding the databinding implementation. Any reason why the ValueMember was copied to the Node.Tag property instead of the Node.Name property? Doing this would have eliminated the need to write a custom find method and use the Nodes.Find() method instead.
- TG
- TG
0
Hi TECH GURU,
Please refer to your first ticket about the same.
Regards,
Please refer to your first ticket about the same.
Regards,
Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Hi TECH GURU,
Stefan
the Telerik team
Please note that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out. For more information on our latest release refer to this blog post.
Best wishes,Stefan
the Telerik team