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

hierarchical radgridview focus

3 Answers 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeejee Unwalla
Top achievements
Rank 1
Jeejee Unwalla asked on 15 Aug 2010, 02:46 PM
I have a heirarchical radgridview.  Lets say the parent is locations and the child is contacts at that location.  I can't seem to figure out which grid has the focus. 

I'm binding a viewmodel to a set of command buttons to edit or delete the currently selected item in the grid.  When the item is a location I want to bind to the location viewmodel but when the focus is on a contact I want the same buttons to be bound to the contact viewmodel instead.  I tried using the row_activated event but that seems to fire only when you double click.  I thought about the SelectionChanged event but it seems that when I switch from the child grid to the parent grid the selectionchanged event is not firing.  Could you provide an example of how I could achieve somthing like this?

3 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 16 Aug 2010, 04:30 PM
Hi Jeejee Unwalla,

 You can try the GotFocus event. If that doesn't work for you, I'll try and make a sample project.

Regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jeejee Unwalla
Top achievements
Rank 1
answered on 17 Aug 2010, 07:37 AM
Will the GotFocus fire as you move between the rows within the parent.  I suppose I could combine the GotFocus event with the SelectionChanged event.
0
Yavor Georgiev
Telerik team
answered on 17 Aug 2010, 12:44 PM
Hello Jeejee Unwalla,

 If you handle GotFocus for your parent RadGridView, the event will fire each time one of the elements contained in the parent (including its children) is focused. Check out this code:

void GridView_GotFocus(object sender, RoutedEventArgs e)
{
    GridViewDataControl grid;
    if (e.OriginalSource is GridViewDataControl)
    {
        grid = e.OriginalSource as GridViewDataControl;
    }
    else
    {
        grid = (e.OriginalSource as UIElement).ParentOfType<GridViewDataControl>();
    }
    System.Diagnostics.Debug.WriteLine(grid.ItemsSource.ToString());
}

This will always try to find the GridView that is closest to the focused element. So if you click a cell in the parent, the event will fire and 'grid' will be the parent. If you click a cell in the hierarchy child, the event will fire and 'grid' will be the child.

Regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Jeejee Unwalla
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Jeejee Unwalla
Top achievements
Rank 1
Share this question
or