Using one datasource

7 posts, 1 answers
  1. Gregory
    Gregory avatar
    47 posts
    Member since:
    Sep 2010

    Posted 24 Jun 2011 Link to this post

    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
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 29 Jun 2011 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Gregory
    Gregory avatar
    47 posts
    Member since:
    Sep 2010

    Posted 30 Jun 2011 Link to this post

    Thanks this will work, ill just have to improve on it

    Regards
  5. Gregory
    Gregory avatar
    47 posts
    Member since:
    Sep 2010

    Posted 30 Jun 2011 Link to this post

    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
  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 05 Jul 2011 Link to this post

    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!

  7. gans
    gans avatar
    48 posts
    Member since:
    Jan 2012

    Posted 16 Feb 2012 Link to this post

    Hi Petar,

    Do you have an example that filters the whole Hierarchy of the tree?
  8. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 21 Feb 2012 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready