Can't get Heirarchal data to show up

2 posts, 0 answers
  1. Chris
    Chris avatar
    3 posts
    Member since:
    Jun 2013

    Posted 25 Jun 2013 Link to this post


    Hi,

    I have a situation where I have successfully shown data in a ParentGrid, but now I have setup a child grid but cant get it to display data.

    XAML:

     <telerik:RadGridView Name="CustomersGrid" ShowInsertRow="True" Grid.Column="0" SelectionChanged="CustomersGrid_SelectionChanged">
                <telerik:RadGridView.ChildTableDefinitions>
                    <telerik:GridViewTableDefinition/>
                </telerik:RadGridView.ChildTableDefinitions>            
                <telerik:RadGridView.HierarchyChildTemplate>
                    <DataTemplate>
                        <telerik:RadGridView Name="ChildGrid" ShowInsertRow="True" Loaded="ChildGrid_Loaded" />
                    </DataTemplate>
                </telerik:RadGridView.HierarchyChildTemplate>
            </telerik:RadGridView>


    C#:

     public MainWindow()
            {
                InitializeComponent();
                var customers = Repo.GetCustomers();
                CustomersGrid.RowIsExpandedChanging += CustomersGrid_RowIsExpandedChanging;
                CustomersGrid.ItemsSource = customers;
                
                DataContext = this;
            }

    This works fine and shows the child grid when clicking on the + sign. The ParentGrid is bound to Customers (Select * FROM Customers) I need to know how to bind the child grids to Agreements (Select * From Agreements where CUST_NO = '" + CUST_NO + "'"). I cant seem to access the Child Grid's itemsource to set the data binding.

    What am I doing wrong?

    Thank you very much!
    Ron
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1216 posts

    Posted 28 Jun 2013 Link to this post

    Hi,

    I would advise you to move the data loading logic into your view model and expose the result as a new property. Then you would be able to bind the ItemsSource to it.

    Regards,
    Ivan Ivanov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top