Accessing selected child row

3 posts, 1 answers
  1. NS
    NS avatar
    189 posts
    Member since:
    Jan 2007

    Posted 02 Jul 2008 Link to this post


    I have a problem with getting the child row that is selected.

    I have a grid with in the first column of the child grid a checkbox to select/deselect.  When the check changed i handle the event.  But i get the parentrow in the selected row and not the child row

    How can i get the selected child row?

    Little info on how i fill the childcolumn
      radGridResubmit.TableDefinition.ChildTableDefinitions[0].AutoGenerateFieldDescriptors = false;  
                        Telerik.Windows.Controls.UI.GridViewDataColumn desc = new Telerik.Windows.Controls.UI.GridViewDataColumn();  
                        desc.HeaderText = "";  
                        desc.UniqueName = "IsSelectedForResubmit";  
                        desc.IsAutoGenerated = true;  
                        desc.CellStyle = new Style();  
                        desc.CellStyle.Setters.Add(new Setter(TemplateProperty, FindResource("CheckBoxColumnTemplateAction")));  
                        desc = new GridViewDataColumn();  
                        desc.IsReadOnly = true;  
                        desc.HeaderText = "ActionName";  
                        desc.UniqueName = "ActionName";  
                        desc.IsAutoGenerated = true;  

  2. Answer
    Jimmy avatar
    16 posts

    Posted 04 Jul 2008 Link to this post

    Hello NS,

    Unfortunately our beta 2 ships with no public API that can return the selected child row in a hierarchical GridView. In order to get it you will have to use the GetParent() method of the VisualTreeHelper class. For example in your event handler you can use something like this:


    DependencyObject gridViewRow = e.OriginalSource as DependencyObject; 
    while (!(gridViewRow is GridViewRow)) 
        gridViewRow = VisualTreeHelper.GetParent(gridViewRow); 

    Now that you have accessed the selected GridViewRow you can use its DataContext.Data property to access the selected GridViewRow data.

    All the best,
    Author jimmy
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. NS
    NS avatar
    189 posts
    Member since:
    Jan 2007

    Posted 07 Jul 2008 Link to this post


    Works like a charm
Back to Top