This is a migrated thread and some comments may be shown as answers.

Using one datasource

6 Answers 59 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
KobusVisagie
Top achievements
Rank 1
KobusVisagie asked on 24 Jun 2011, 10:33 AM
Hi Everyone

Is it possible to use only one DataTable as a DataSource to create a treeview.
Basically there will be two keys in the table, the first key will be the primery key and the second key(Parent Key) will tell the column to which primery key it should link too.

Somthing like this

Prime Key    Parent Key    Item
1                  null                Car
2                  1                    Tyre
3                  1                    Fuel
4                  2                    Rims
P.S. Null, means it's not linking to anything and it will be the first item(Node) in the tree

If it's possible, can someone give me an example?

Regards

6 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 29 Jun 2011, 01:20 PM
Hello Gregory,

In the following help article we are demonstrating how to bind a Telerik`s WPF RadTreeView to SelfReferencing Data. I believe it could be a great starting point for you. Please feel free to ask if you need further assistance or info.

Regards,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
KobusVisagie
Top achievements
Rank 1
answered on 30 Jun 2011, 09:12 AM
Thanks this will work, ill just have to improve on it

Regards
0
KobusVisagie
Top achievements
Rank 1
answered on 30 Jun 2011, 12:41 PM
Hi Telerik Team

Is there any way of filtering through nodes using this example? by means of someone typing into a textbox as an example?

Regards
0
Petar Mladenov
Telerik team
answered on 05 Jul 2011, 02:51 PM
Hello Gregory,

A basic filtration could be performed in the TextBox`a TextChanged event handler like so:
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
       {
           this.radTreeView.ItemsSource = (this.radTreeView.ItemsSource as IEnumerable<DataItem>).Where(x => x.Text.EndsWith("2"));
       }
This filters only the root level collection, if you need to filter the whole hierarchy, you will have to rebuild it again and then rebinding.

Regards,
Petar Mladenov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
gans
Top achievements
Rank 1
answered on 17 Feb 2012, 02:14 AM
Hi Petar,

Do you have an example that filters the whole Hierarchy of the tree?
0
Petar Mladenov
Telerik team
answered on 21 Feb 2012, 05:08 PM
Hello Gans,

 Currently, we don't have such example. You can implement this by traversing and re-creating the whole ViewModel hierarchy, starting from the deepest levels and ending with the root level.

Regards,
Petar Mladenov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TreeView
Asked by
KobusVisagie
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
KobusVisagie
Top achievements
Rank 1
gans
Top achievements
Rank 1
Share this question
or