new RadTreeView() and databinding

4 posts, 0 answers
  1. SWAYAM KAR
    SWAYAM KAR avatar
    6 posts
    Member since:
    Mar 2010

    Posted 08 Apr 2010 Link to this post

    Hello,

    Databinding doesn't seem to work for me if I create a RadTreeview instance in the code and assign a HierarchicalDataTemplate as the item template. Here is what I am doing.

     

    _treeInstallDates.ItemTemplate =

    this.Resources["InstallTreeNodes"] as Telerik.Windows.Controls.HierarchicalDataTemplate;

     

     

    ObservableCollection<POSInstallTreeModel> itemsToBind = new ObservableCollection<POSInstallTreeModel>();

     

    installItems.ForEach(p => itemsToBind.Add(p));

    _treeInstallDates.IsVirtualizing =

    true;

     

    _treeInstallDates.ItemsSource = itemsToBind;

    _treeInstallDates.UpdateLayout();

    And here is the XAML

     

     

     

    <telerik:HierarchicalDataTemplate x:Key="InstallTreeLeafItems">

     

     

     

     

     

     

     

    <StackPanel Orientation="Horizontal">

     

     

     

     

     

     

     

    <Image Source="{Binding ImageSrc}" ToolTipService.ToolTip="{Binding TooltipText}">

     

     

     

    </Image>

     

     

     

     

     

     

     

    <TextBlock Text="{Binding StoreNum}"></TextBlock>

     

     

     

     

     

     

     

    </StackPanel>

     

     

     

     

     

     

     

    </telerik:HierarchicalDataTemplate>

     

     

     

     

     

     

     

    <telerik:HierarchicalDataTemplate x:Key="InstallTreeNodes" ItemTemplate="{StaticResource InstallTreeLeafItems}" ItemsSource="{Binding StoreData}">

     

     

     

     

     

     

     

    <TextBox Text="{Binding Path=POSInstallDate}"></TextBox>

     

     

     

     

     

     

     

    </telerik:HierarchicalDataTemplate>

     

     

     

     

     

     

     

     

    What am I doing wrong here?


  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 12 Apr 2010 Link to this post

    Hi SWAYAM KAR,

    I am not sure what are the issues you are facing with your scenario. Can you please elaborate a bit? Also, from  the code snippet you provided I couldn't tell what might be causing problems.

    Therefore, I prepared an example for you. Can you please take a look at it and let me know if this is what you had in mind? If not, can you please modify it to reproduce the issue you are facing?

    All the best,
    Tina Stancheva
    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. Rakesh
    Rakesh avatar
    42 posts
    Member since:
    Jun 2010

    Posted 13 Jul 2010 Link to this post

    Hi Tina,

    I have an issue with the databinding of treeviw in SL 4 VS 2010. C#.

    I have an hierarchial data meaning all the root and children belong to the same class.

    for e.g. lookup goes like this.

    recruiterno          trackno
    (null)                     100
    100                        1001
    100                        1002
    1001                    10011

    so, I am trying to bind the data in treeview and when I looked at the different types of binding that one can do in the treeview,  I looked at the examples like object datasource , hierarchial datsource
    but no one example mentions how to bind heirarchial data of same class type to the treeviw. I have been researching all over for the past couple of days. If you can help me out, it would be great!!!

    In asp .net: this is such a good example but I cant find like this one in silverlight
    http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/databinding/defaultcs.aspx

    Rakesh
  4. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 14 Jul 2010 Link to this post

    Hello Rakesh,

    Thank you for the clarification. Here is an example of how you can populate the RadTreeView with data from a self-referencing hierarchy.

    Please take a look at it and let me know if it works for you or if you need more info.

    All the best,
    Tina Stancheva
    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
Back to Top