Get values of selected row in child grid

7 posts, 1 answers
  1. Peter Meinl
    Peter Meinl avatar
    35 posts
    Member since:
    Jan 2010

    Posted 08 Aug 2010 Link to this post

    How can I get the values of the row selected in the child grid of a hierachical grid.

    My hierarchical GridView is bound to the results of an OData service:
    ApprovalRequests
    ..Approvals

    In a button click event I want to access the selected values.
  2. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Aug 2010 Link to this post

    Hi,

     Why not use MVVM instead? The approach demonstrated in this blog will work no matter if the grid is parent or child. 

    Sincerely yours,
    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Peter Meinl
    Peter Meinl avatar
    35 posts
    Member since:
    Jan 2010

    Posted 10 Aug 2010 Link to this post

    Thanks for your fast answer.

    Using MVVM looked like too much code to me for simply getting the selected child row.
    I replaced the hierarchical RadGridView with two synchronized standard DataGrids instead.
  5. Anand
    Anand avatar
    2 posts
    Member since:
    May 2009

    Posted 21 Sep 2010 Link to this post

    Is there another way to solve this issue with out using MVVM or going with two standard datagrids?
    Thank you,
    Happy
  6. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 23 Sep 2010 Link to this post

    Hi Anand,

    There are several ways to get the selected items depending on your particular scenario. Are you using a button to retrieve the child selected items? When is the button placed - is it on the parent rows?

    Kind regards,
    Milan
    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
  7. Anand
    Anand avatar
    2 posts
    Member since:
    May 2009

    Posted 23 Sep 2010 Link to this post

    Thank you for your response.

    Well I have Parent Grid which shows the list of Requests (Request Object --> which has a collection of Sample Objects); the child grid has the Sample Object. (I used the demo example and it works like a charm)

    When I double click on the Parent grid I am supposed to pass the Request Object (row) to a Request screen and it handles updates etc (this is working), similarly on double click of the Child grid I would like to pass the Sample Object to a Sample screen and it handles updates etc; this is not happening - instead it gives the Request object (row) all the time. (btw I am using MouseDoubleClick Event).

    Regards,
    Anand

  8. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 29 Sep 2010 Link to this post

    Hello Anand,

    If you are using HierarchyChildTemplate or a RowDetailsTemplate you can easily subscribe to the RowActivated event of the child grid and retrieve the activated row. For example:

    <telerik:RadGridView Grid.Row="0" 
                         Name="clubsGrid" 
                         ItemsSource="{Binding Clubs}" 
                         Margin="5">
        <telerik:RadGridView.HierarchyChildTemplate>
            <DataTemplate>
                <telerik:RadGridView Name="playersGrid" 
                                 ItemsSource="{Binding Players}" 
                                     RowActivated="playersGrid_RowActivated_1"/>
                    
            </DataTemplate>
        </telerik:RadGridView.HierarchyChildTemplate>
     
    </telerik:RadGridView>

    private void playersGrid_RowActivated_1(object sender, RowEventArgs e)
    {
        var clickedDataItem = e.Row.DataContext;
      
        // process item
    }

    Hope this works.


    Greetings,
    Milan
    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
Back to Top
UI for WPF is Visual Studio 2017 Ready