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

Hierarchy gridview parent or child?

4 Answers 127 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jonathan Miller
Top achievements
Rank 1
Jonathan Miller asked on 17 Sep 2008, 07:06 PM
In a hierarchy gridview, is there a nested depth value, or a way to tell if the change is from a parent or child row?

void radGridView_SelectionChanged(object sender, SelectionChangeEventArgs e)

Thanks

4 Answers, 1 is accepted

Sort by
0
Atanas
Telerik team
answered on 18 Sep 2008, 10:27 AM
Hi Jonathan Miller,

The SelectionChangeEventArgs caontains a property called DataControl. It returns the RadGridView control where the selection event happened.

Sincerely yours,
Atanas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jonathan Miller
Top achievements
Rank 1
answered on 18 Sep 2008, 05:43 PM
Thank you for the reply. 

(Is a hierarchy)

Using DataControl, how can I determine if a parent or child row was clicked?
0
Atanas
Telerik team
answered on 19 Sep 2008, 08:20 AM
Hello Jonathan Miller,

Our SelectionChanged event is Routed Tunnel event. It is fired for the parent grid first and then for the child grid.
To determine if a parent or a child row is clicked you have to cast the DataControl property of the SelectionChangeEventArgs to GridViewDataControl. GridViewDataControl has a property called ParentRow. If this property is null, the top level parent grid was clicked and vice versa if the property is not null, the child grid is clicked.

GridViewDataControl dataControl = (GridViewDataControl) e.DataControl; 
GridViewExpandableRow parentRow = (dataControl.ParentRow as GridViewExpandableRow); 

I am attaching you an example demonstrating this scenario.

All the best,
Atanas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jonathan Miller
Top achievements
Rank 1
answered on 22 Sep 2008, 02:10 PM
works great, thanks!

As a side note, my code-behind still hows parentRow = null, but form some reason the code (if parentRow != null) works.  Oh well, It is working. Thanks again
Tags
GridView
Asked by
Jonathan Miller
Top achievements
Rank 1
Answers by
Atanas
Telerik team
Jonathan Miller
Top achievements
Rank 1
Share this question
or