RadGridView in RowDetailsTemplate

2 posts, 1 answers
  1. Rouf
    Rouf avatar
    5 posts
    Member since:
    Mar 2014

    Posted 10 Jun Link to this post

    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>

     

                    

  2. Answer
    Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    405 posts

    Posted 11 Jun Link to this post

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