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

Get values of selected row in child grid

6 Answers 309 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter Meinl
Top achievements
Rank 1
Peter Meinl asked on 08 Aug 2010, 05:07 PM
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.

6 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 09 Aug 2010, 06:55 AM
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
0
Peter Meinl
Top achievements
Rank 1
answered on 10 Aug 2010, 11:43 AM
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.
0
Anand
Top achievements
Rank 1
answered on 22 Sep 2010, 12:55 AM
Is there another way to solve this issue with out using MVVM or going with two standard datagrids?
Thank you,
Happy
0
Milan
Telerik team
answered on 23 Sep 2010, 06:42 PM
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
0
Anand
Top achievements
Rank 1
answered on 23 Sep 2010, 07:01 PM
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

0
Milan
Telerik team
answered on 29 Sep 2010, 02:05 PM
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
Tags
GridView
Asked by
Peter Meinl
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Peter Meinl
Top achievements
Rank 1
Anand
Top achievements
Rank 1
Milan
Telerik team
Share this question
or