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

RadGridView masterdetail sample for WPF?

4 Answers 237 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Enric
Top achievements
Rank 1
Enric asked on 19 Jan 2014, 02:52 PM
Hi ya, I'm looking for some WPF sample where I can connect two Sql tables using a couple of RadGridView controls.

Can you please be so kind to provide some link or sample related to?

Thanks in advance and regards,

4 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 22 Jan 2014, 02:43 PM
Hello Enric,

You can find information on how to connect RadGridView to SQL tables in the following articles: article1, article2. You can also see the GridView's WPF demos (link) falling under the category DataBinding.

Regards,
Hristo
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 >>
0
Enric
Top achievements
Rank 1
answered on 22 Jan 2014, 10:17 PM
Thanks Hristo for your response.

Could you be please more specific? I mean, the couple of links provided doesn't verse about master-detail relationship between two tables.
Thanks in advance for any advice or additional support.
0
Hristo
Telerik team
answered on 27 Jan 2014, 04:53 PM
Hi,

In your case the master-detail relationship can be achieved by using the GridView's RowDetails property. For more information on them, please see the following article in our documentation.
You can also see the following online demo. The demo is for Silverlight, however the same steps can be applied in WPF. Another way of achieving master-detail relationship is to use hierarchical GridView (link).

I have also attached a sample project.

Regards,
Hristo
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 >>
0
Enric
Top achievements
Rank 1
answered on 27 Jan 2014, 07:45 PM
Thanks a lot for your post.

Could you be please so kind to analyse this XAML snippet (extracted from the attached sample provided for you)?

In your sample I see a couple of classes (Club and Player) which are inheriting ObservableCollection collections.

Just in case, I suppose that in my goal I could use a couple of Sql views or datasets in their place.

If so and one bit further: how can I connect both tables??

You use this LINQ expression:
(How can I proceed with my ADO objects??)

        public static ObservableCollection<Player> GetPlayers()
        {
            return new ObservableCollection<Player>(Club.GetClubs().SelectMany(c => c.Players));

        }

        <DataTemplate x:Key="RowDetailsTemplate">
                <telerik:RadGridView Name="playersGrid"
                                     ItemsSource="{Binding Players}"
                                     AutoGenerateColumns="False">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Number}"/>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>
            </DataTemplate>
        </Grid.Resources>
        <telerik:RadGridView Grid.Row="0"
                             Name="clubsGrid"
                             ItemsSource="{Binding Clubs}"
                             AutoGenerateColumns="False"
                             RowDetailsTemplate="{StaticResource RowDetailsTemplate}"
                             Margin="5">
            <telerik:RadGridView.Columns>
                <telerik:GridViewToggleRowDetailsColumn/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Established}"
                                            Header="Est."
                                            DataFormatString="{}{0:yyyy}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding StadiumCapacity}"
                                            Header="Stadium"
                                            DataFormatString="{}{0:N0}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
Tags
General Discussions
Asked by
Enric
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Enric
Top achievements
Rank 1
Share this question
or