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

CellEditTemplate TabNavigation

5 Answers 195 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 30 Nov 2011, 06:00 PM
I have a CellEditTemplate that contains a UserControl composed of two comboboxes.  I wish to have the first combobox selected when I tab into the cell, then have the second combobox selected with the next tab. (Keyboard focus so that arrow keys can move through the items in the combobox)

Both comboboxes have their IsTabStop properties set to True.  The control in the CellEditTemplate (DataTemplate) has its IsTabStopProperty set to true.

How can I accomplish this?

Thank you in advance,
Scott Lee

5 Answers, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 01 Dec 2011, 02:42 PM
Is there anyone here that can help?
0
Dimitrina
Telerik team
answered on 01 Dec 2011, 04:57 PM
Hi Scott,

 I have tested your scenario and I have created a sample project based on your description, defining only a CellEditTemplate. Have you defined a CellTemplate as well?

You can test that when you are in edit mode in Cell 1 and a Tab key is pressed, the Cell 2 goes into edit mode and the first ComboBox is selected. I can navigate with the keyboard buttons on it.

Please check the project and let me know how it is different from yours.

Best wishes,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Scott
Top achievements
Rank 1
answered on 01 Dec 2011, 05:47 PM
Here is the data column xaml:

<telerik:GridViewDataColumn Header="Unit of Measure"
                                            Width="205"
                                            SortMemberPath="UomSelectorViewModel.SelectedUnit"
                                            UniqueName="UnitOfMeasure">
 
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding UomSelectorViewModel.SelectedUnit.Description, Mode=OneWay}"
                                       Height="18"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                    <telerik:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
                            <common:UnitOfMeasurePicker Viewmodel="{Binding UomSelectorViewModel, Mode=OneWay}"
                                                        Height="18"
                                                        FocusManager.IsFocusScope="True"
                                                        input:KeyboardNavigation.TabNavigation="Local"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>


Here is my user control xaml

<UserControl x:Class="Rgs.SADotNet.Presentation.UnitOfMeasurePicker"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="25" d:DesignWidth="195">
    <Grid Width="196">
        <ComboBox HorizontalAlignment="Left"
                  Name="quantityTypeComboBox"
                  VerticalAlignment="Stretch"
                  Width="120"
                  ItemsSource="{Binding QuantityTypes}"
                  DisplayMemberPath="Description"
                  SelectedItem="{Binding SelectedQuantityType}"
                  IsTabStop="True"
                  TabIndex="0"/>
        <ComboBox HorizontalAlignment="Stretch"
                  Margin="120,0,0,0"
                  Name="unitComboBox"
                  VerticalAlignment="Stretch"
                  ItemsSource="{Binding Units}"
                  SelectedItem="{Binding SelectedUnit}"
                  ToolTip="{Binding Path=SelectedUnit.Description}"
                  IsTabStop="True"
                  TabIndex="1">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal"
                                Width="75"
                                Background="Transparent"
                                ToolTip="{Binding Description}">
                        <TextBlock Text="{Binding Symbol}" />
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
    </Grid>
</UserControl>


As it is, I can tab to the cell, the user control's first combo is selected.  The next tab leaves the cell instead of selecting the next combo.
0
Scott
Top achievements
Rank 1
answered on 02 Dec 2011, 03:02 PM
You can consider this issue closed.  The problem was created because I handle the KeyDown event for the grid when my software is in a "add" mode to enable a tab on the last row, last column to be used to insert a new item into the ObservableCollection that my grid is bound to.  My solution is to handle the KeyDown on the first ComboBox in my UserControl, move focus to the second ComboBox and set e.Handled to true.

However, when I abort the add by twice pressing the escape key, my new item is not removed from the ObservableCollection.  I cannot seem to find any event to handle that allows me to remove it in code.  Help please.
0
Dimitrina
Telerik team
answered on 05 Dec 2011, 09:32 AM
Hi Scott,

 As I understand when you are in the last row, you press the Tab key and a new row has been inserted. Do you use the BeginInsert() method of the RadGridView for the insert?

I have tried to reproduce the described behaviour, but I was not able to. Would it be possible for you to send us a very simple project showing this issue?

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Scott
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or