SelectionChanged event in hierarchial RadGridView

3 posts, 0 answers
  1. James
    James avatar
    7 posts
    Member since:
    Oct 2016

    Posted 31 Dec 2020 Link to this post

    For a SelectionChanged event in a hierarchical RadGridView, how do I test to determine which template had a row selection change?

  2. Nadya
    Admin
    Nadya avatar
    510 posts

    Posted 04 Jan Link to this post

    Hello, James,

    In order to know whether the SelectionChanged event is triggered by the master template or by a child template, you can check whether the Parent property of the corresponding GridViewTemplate is null. This will ensure that the row is from the master template. Please refer to the following code snippet:

     private void RadGridView1_SelectionChanged(object sender, EventArgs e)
     {
         var selectedRow = this.radGridView1.SelectedRows[0];
         bool isMaster = (selectedRow.ViewTemplate.Parent == null);
         if (isMaster)
         {
             Console.WriteLine("Master");
         }
         else
         {
             Console.WriteLine("Template");
         }
     }
    

    I hope this helps. Let me know if you have other questions. 

    Regards,
    Nadya
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

  3. James
    James avatar
    7 posts
    Member since:
    Oct 2016

    Posted 04 Jan in reply to Nadya Link to this post

    This helps a bunch. Thanks Nadya.
Back to Top