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

Can't get Heirarchal data to show up

1 Answer 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 25 Jun 2013, 01:43 PM

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

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 28 Jun 2013, 01:35 PM
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 >>
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or