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

RadGridView in RowDetailsTemplate

1 Answer 82 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rouf
Top achievements
Rank 1
Rouf asked on 10 Jun 2019, 02:48 PM

My RadGridView is binded to a List of  (say) Samples. In RowDetailsTemplate I want to show another RadGridView which will show the related records from the List (say) Analysis. The main RadGridView GrdSamples is bound in Codebehind as :

GrdSamples.ItemsSource=SamplesViewModel.GetAll();

 

How can I bind the Child GridView GrdAnalysis in the same way. And on which event I will get the GrdSamples ID, So that I can use Some thing like

var SampleID = ? 
GrdAnalysis.ItemsSource=AnalysisViewModel.Get(SampleID);

Here is the XAML

<telerik:RadGridView x:Name="GrdSamples" AutoGenerateColumns="False">
     <telerik:RadGridView.Columns>...</telerik:RadGridView.Columns>
         <telerik:RadGridView.RowDetailsTemplate>
              <DataTemplate>
                   <telerik:RadGridView x:Name="GrdAnalysis" AutoGenerateColumns="False">
              </DataTemplate>
          </telerik:RadGridView.RowDetailsTemplate
</telerik:RadGridView>

 

                

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir Stoyanov
Telerik team
answered on 11 Jun 2019, 10:27 AM
Hello Rouf,

Thank you for the provided code snippets. 

In order to achieve what you are going for you can utilize the RowDetailsVisibilityChanged event. In that event you have access to the object bound to that row and also the details element. Here is some sample code:
private void gridView_RowDetailsVisibilityChanged(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
        {
            // you can get the sample id from that object
            var object = e.Row.Item;
 
            (e.DetailsElement as RadGridView).ItemsSource = // Get items for child grid
        }

I hope you find this helpful. 

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Rouf
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or