RadGridView masterdetail sample for WPF?

4 posts, 0 answers
  1. Enric
    Enric avatar
    32 posts
    Member since:
    Apr 2013

    Posted 19 Jan 2014 Link to this post

    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,
  2. Enric
    Enric avatar
    32 posts
    Member since:
    Apr 2013

    Posted 22 Jan 2014 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Hristo
    Admin
    Hristo avatar
    41 posts

    Posted 27 Jan 2014 Link to this post

    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 >>
  5. Enric
    Enric avatar
    32 posts
    Member since:
    Apr 2013

    Posted 27 Jan 2014 in reply to Hristo Link to this post

    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>
Back to Top