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

RadGridView TableRelation not working anymore

7 Answers 52 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steffen
Top achievements
Rank 1
Veteran
Steffen asked on 26 Feb 2010, 10:50 AM
Hi,

I got some hierachical RadGridViews in my application, bound to untyped DataSets.
They are not showing any child-rows with the new beta (only the column-headers are visible).

Here is my code:
                TableRelation relation = new TableRelation(); 
                relation.FieldNames.Add(new FieldDescriptorNamePair("id", "master_id")); 
           
                GridViewTableDefinition childTable = new GridViewTableDefinition() 
                { 
                    DataSource = myDataSet.Tables[childTable].DefaultView, 
                    Relation = relation,   
                }; 
                 
                radgv_ordersAndOffersToSchedule.TableDefinition.ChildTableDefinitions.Clear(); 
                radgv_ordersAndOffersToSchedule.TableDefinition.ChildTableDefinitions.Add(childTable); 
 
radgv_ordersAndOffersToSchedule.ItemsSource = myDataSet.Tables["masterTable"].DefaultView; 

I tried a lot of things to get it working again, but had no success.

Best Regards
Steffen

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 01 Mar 2010, 09:10 AM
Hi Steffen,

I've just tried this however everything worked fine on my end. Please check the attached project for reference.

All the best,
Vlad
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
Steffen
Top achievements
Rank 1
Veteran
answered on 01 Mar 2010, 10:16 AM
Hi,

to reproduce my problem AutoGenerateColumns has to set to false and a childtemplate has to be used.
Just change the xaml and the example-project will show the described behaviour:
        <telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False"
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn Header="Customer" DataMemberBinding="{Binding Path=CustomerID}" /> 
            </telerik:RadGridView.Columns> 
 
            <telerik:RadGridView.HierarchyChildTemplate> 
                <DataTemplate> 
                    <telerik:RadGridView x:Name="RadGridView2" AutoGenerateColumns="False"
                        <telerik:RadGridView.Columns> 
                            <telerik:GridViewDataColumn Header="Order" DataMemberBinding="{Binding Path=OrderID}" /> 
                        </telerik:RadGridView.Columns> 
                    </telerik:RadGridView> 
                </DataTemplate> 
            </telerik:RadGridView.HierarchyChildTemplate> 
        </telerik:RadGridView> 
Maybe I'm doing something wrong, but it worked before.

Best Regards
Steffen
0
Vlad
Telerik team
answered on 01 Mar 2010, 12:12 PM
Hi Steffen,

Since you have defined custom HierarchyChildTemplate the default grid auto-generated hierarchy will not work - currently your child grid is not bound at all. To achieve your goal you need to assign ItemsSource for the child grid. I've tried our Q3 2009 release however this didn't worked.

Best wishes,
Vlad
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
Steffen
Top achievements
Rank 1
Veteran
answered on 01 Mar 2010, 01:33 PM
Hi Vlad,
First, thank you for your quick response.

I used  2009.3.916.35 in my application (AutoGenerateHierarchyFromDataSet still exists here and is set to false).
It seems that already in Q3-final its not working anymore. I thought the childtable would get its data from the DataRelation's DataSource-property. I also tried to set the DataContext to the DataSet and set both ItemsSources to {Binding Path=Customers}/{Binding Path=Orders}. But this also gives me empty child-rows.

Here is the code which works(tested) with 2009.3.916.35:
        public Window1() 
        { 
            InitializeComponent(); 
 
            var myDataSet = new Northwind(); 
 
            new CustomersTableAdapter().Fill(myDataSet.Customers); 
            new OrdersTableAdapter().Fill(myDataSet.Orders); 
 
            TableRelation relation = new TableRelation(); 
            relation.FieldNames.Add(new FieldDescriptorNamePair("CustomerID", "CustomerID")); 
 
            GridViewTableDefinition childTable = new GridViewTableDefinition() 
            { 
                DataSource = myDataSet.Tables["Orders"].DefaultView, 
                Relation = relation
            }; 
 
            RadGridView1.TableDefinition.ChildTableDefinitions.Clear(); 
            RadGridView1.TableDefinition.ChildTableDefinitions.Add(childTable); 
 
            RadGridView1.ItemsSource = myDataSet.Tables["Customers"].DefaultView; 
        } 

<Window x:Class="WpfApplication1.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    Title="Window1"
    <Grid> 
        <telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False" IsReadOnly="True" AutoGenerateHierarchyFromDataSet="False"  > 
        <!--<telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False" IsReadOnly="True" >--> 
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn Header="Customer" DataMemberBinding="{Binding Path=CustomerID}" /> 
            </telerik:RadGridView.Columns> 
 
            <telerik:RadGridView.HierarchyChildTemplate> 
                <DataTemplate> 
                    <telerik:RadGridView x:Name="RadGridView2" AutoGenerateColumns="False" > 
                        <telerik:RadGridView.Columns> 
                            <telerik:GridViewDataColumn Header="Order" DataMemberBinding="{Binding Path=OrderID, Mode=OneWay}" /> 
                        </telerik:RadGridView.Columns> 
                    </telerik:RadGridView> 
                </DataTemplate> 
            </telerik:RadGridView.HierarchyChildTemplate> 
        </telerik:RadGridView> 
    </Grid> 
</Window> 



So what do I have to change to make it work again (because I also use untyped DataSets I can not provide the child-data through a property on the parentrow which would be a solution to avoid the Relation and do it through normal Property-Bindings)?

Best Regards
Steffen

0
Vlad
Telerik team
answered on 01 Mar 2010, 02:02 PM
Hello Steffen,

Indeed for Q3 we decided to not bind explicitly any child grid if this grid is defined in a custom HierarchyChildTemplate since this caused lots of problems however you can easily customize your child grid programmatically using DataLoading event instead HierarchyChildTemplate.

Please check the attached example and let me know if this will work for you.

Regards,
Vlad
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
Steffen
Top achievements
Rank 1
Veteran
answered on 02 Mar 2010, 09:17 AM
Hi,
thank you for pointing out to me what the problem is.
While your solution works it has some downsides in my scenarion (my inner gridviews have a lot of events and stuff).
So I tried it the "oldschool"-ADO-way by binding the ItemsSource of the child-template to the ADO-relation.
It is simple and it works! But I'm not sure if this is officially supported. 
    public partial class Window1 : Window 
    { 
        public Window1() 
        { 
            InitializeComponent(); 
 
            var myDataSet = new Northwind(); 
 
            new CustomersTableAdapter().Fill(myDataSet.Customers); 
            new OrdersTableAdapter().Fill(myDataSet.Orders); 
 
            TableRelation relation = new TableRelation(); 
            relation.FieldNames.Add(new FieldDescriptorNamePair("CustomerID", "CustomerID")); 
 
            GridViewTableDefinition childTable = new GridViewTableDefinition() 
            { 
                DataSource = myDataSet.Tables["Orders"].DefaultView, 
                Relation = relation
            }; 
 
            RadGridView1.TableDefinition.ChildTableDefinitions.Clear(); 
            RadGridView1.TableDefinition.ChildTableDefinitions.Add(childTable); 
 
 
            RadGridView1.DataContext = myDataSet.Tables["Customers"].DefaultView; 
        } 
    } 
 
 
        <telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False" ItemsSource="{Binding}"
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn Header="Customer" DataMemberBinding="{Binding Path=CustomerID}" /> 
            </telerik:RadGridView.Columns> 
             
            <telerik:RadGridView.HierarchyChildTemplate> 
                <DataTemplate> 
                    <telerik:RadGridView x:Name="RadGridView2" AutoGenerateColumns="False" ItemsSource="{Binding Path=FK_Orders_Customers}"
                        <telerik:RadGridView.Columns> 
                            <telerik:GridViewDataColumn Header="Order" DataMemberBinding="{Binding Path=OrderID}" /> 
                        </telerik:RadGridView.Columns> 
                    </telerik:RadGridView> 
                </DataTemplate> 
            </telerik:RadGridView.HierarchyChildTemplate> 
        </telerik:RadGridView> 


Best Regards
Steffen


0
Accepted
Vlad
Telerik team
answered on 02 Mar 2010, 09:20 AM
Hello Steffen,

Indeed you can use such approach to achieve your goal!

Greetings,
Vlad
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.
Tags
General Discussions
Asked by
Steffen
Top achievements
Rank 1
Veteran
Answers by
Vlad
Telerik team
Steffen
Top achievements
Rank 1
Veteran
Share this question
or