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

GridView does not get focus when the row header of the selected row is clicked from other focus scope

8 Answers 231 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Arthur
Top achievements
Rank 1
Arthur asked on 30 Jun 2015, 09:13 AM

Hi,

I have the following scenario. I have a RadGridView with a ToolBar above, where the ToolBar contains a TextBox (Filter). The textbox is inside the tool bar's focus scope which is different from the main focus scope of the grid.

If I select a row, go to the filter text box in the tool bar and click on the grid without beginning edit or changing selection (for example on the selected row header) the keyboard focus is not transfered back to the gridview. This is programmed this way in GridViewRow.OnMouseLeftButtonDown.

On the other hand if I look at the TreeListViewRow instead of GridViewRow there is an explicit OnMouseDown-Handler which solves the problem for TreeListViews.

My question ist, why is it implemented this way for GridViewRows? A keyboard focus should always transfer on mouse down, even if the target element is the focused element in its focus scope.

Arthur

8 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 02 Jul 2015, 08:55 AM
Hello Arthur,

I must be missing something here as I am not able to reproduce the issue on my side. Will it be possible to take a look at the sample project attached and let me know whether you can reproduce the behavior on it and what the steps for that are ?


Regards,
Maya
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Arthur
Top achievements
Rank 1
answered on 02 Jul 2015, 10:26 AM

Hi Maya,

 

it is simple to reproduce with your sample. To see the problem just use snoop to track the current Keyboard.FocusedElement. Here the steps:

1) Start program 

2) Attach snoop or other tool to track keyboard focus

3) Click on row header near "Liverpool" -> Keyboard focus moved to radgridview -> OK

4) Click on text box in toolbar -> Keyboard focus moved to textbox -> OK

5) Click on the same row header near "Liverpool" as before without clicking anywhere else -> Focus stays in textbox -> NOK

 

0
Arthur
Top achievements
Rank 1
answered on 02 Jul 2015, 10:28 AM
Please do not missread the steps. I really mean RowHeader not ColumnHeader. Just to save communication cycles. :-)
0
Maya
Telerik team
answered on 02 Jul 2015, 10:59 AM
Hello Arthur,

Indeed, you are right. Thanks for the clarification. I will update the behavior so that it is similar to the one of RadTreeListView. If the fix passes our QA procedures, it will be available in our internal build on Monday. You can follow the progress of the issue in our feedback portal.
I also updated your Telerik points for the project and the assistance with the steps.


Regards,
Maya
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Christopher
Top achievements
Rank 1
answered on 17 May 2016, 02:10 PM

Hello,

I have a similar situation but with the column headers. Shouldn't clicking a column header also bring keyboard focus to the RadGridView? Clicking the area of the header that isn't a column, or a group column header if you have one brings it to focus, but clicking an actual column header does not.

If this is how this was designed how would you get around it?

Thanks,

Chris

0
Maya
Telerik team
answered on 17 May 2016, 02:42 PM
Hello Christopher,

The easiest way would be to handle Sorting event of RadGridView that will be thrown on clicking the column header and perform the logic you want inside.

Regards,
Maya
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Arthur
Top achievements
Rank 1
answered on 17 May 2016, 03:07 PM

Hi,

my solution to the problem was that I have written a behavior which is attached by default via our implicit grid style. The behavior does the following and could be adapted to the column header problem also:

private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    GridViewRow control = (GridViewRow)d;
 
    if (control != null)
    {
        if ((bool)e.NewValue)
        {
            control.AddHandler(GridViewRow.MouseDownEvent, (MouseButtonEventHandler)OnMouseDown, true);
        }
        else
        {
            control.RemoveHandler(GridViewRow.MouseDownEvent, (MouseButtonEventHandler)OnMouseDown);
        }
    }
}
 
private static void OnMouseDown(object sender, MouseButtonEventArgs e)
{
    GridViewRow control = (GridViewRow)sender;
 
    if (!control.IsKeyboardFocusWithin && control.GridViewDataControl != null)
    {
        control.GridViewDataControl.Focus();
    }
}

0
Maya
Telerik team
answered on 18 May 2016, 07:28 AM
Hello Arthur,

So, you have found an even better solution :)

Regards,
Maya
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Arthur
Top achievements
Rank 1
Answers by
Maya
Telerik team
Arthur
Top achievements
Rank 1
Christopher
Top achievements
Rank 1
Arthur
Top achievements
Rank 1
Share this question
or