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

Accessing selected child row

2 Answers 44 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
NS
Top achievements
Rank 1
NS asked on 02 Jul 2008, 01:20 PM
Hi,

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")));  
                    radGridResubmit.TableDefinition.ChildTableDefinitions[0].FieldDescriptors.Add(desc);  
 
                     
                    desc = new GridViewDataColumn();  
                    desc.IsReadOnly = true;  
                    desc.HeaderText = "ActionName";  
                    desc.UniqueName = "ActionName";  
                    desc.IsAutoGenerated = true;  
                    radGridResubmit.TableDefinition.ChildTableDefinitions[0].FieldDescriptors.Add(desc);  
                    

Regards

2 Answers, 1 is accepted

Sort by
0
Accepted
Jimmy
Telerik team
answered on 04 Jul 2008, 02:21 PM
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
0
NS
Top achievements
Rank 1
answered on 07 Jul 2008, 10:49 AM
tnx,

Works like a charm
Tags
General Discussions
Asked by
NS
Top achievements
Rank 1
Answers by
Jimmy
Telerik team
NS
Top achievements
Rank 1
Share this question
or