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

A cell remains in edit mode, even though control has moved to another cell

7 Answers 152 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ujjwal Lahoti
Top achievements
Rank 1
Ujjwal Lahoti asked on 07 May 2010, 12:27 PM
I have a grid, where all the columns are of type: GridViewDataColumn.

One column (Modulation) in edit mode consists of a combo box and a button. Another grid is a TextBox.
The problem is that when I am changing the selection of the Combo box, and then move to another column (Fading Doppler), the "Modulation" column remains in edit, it doesn't loose focus.

Essentially what I have observed is that, since the fact that the another column is a TextBox, this problem happens. If the control is something else, the problem doesn't happen.

Here is the declaration of the columns:

                <!-- Modulation selection column -->
                <telerik:GridViewDataColumn Header="Modulation" Width="150" DataMemberBinding="{Binding Modulation, Mode=TwoWay}" TextAlignment="Center" >
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                            <TextBlock Text="{Binding Modulation}" Foreground="{Binding Path, Converter={StaticResource colorConverter}}"/>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                        <telerik:GridViewDataColumn.CellEditTemplate >
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                <ComboBox Loaded="Editor_Loaded" Width="100" Margin="5, 0, 0, 0" Foreground="{Binding Path, Converter={StaticResource colorConverter}}" Text="{Binding Modulation, Mode=TwoWay}" Background="White"  SelectionChanged="modulationChanged">
                                        <ComboBoxItem>Static</ComboBoxItem>
                                        <ComboBoxItem>Rayleigh</ComboBoxItem>
                                        <ComboBoxItem>Rician</ComboBoxItem>
                                </ComboBox>
                                <Button Content="More..." Foreground="{Binding Path, Converter={StaticResource colorConverter}}"/>
                                </StackPanel>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellEditTemplate>
                    </telerik:GridViewDataColumn>

                <!-- Fading Doppler -->
                <telerik:GridViewDataColumn Width="110" DataMemberBinding="{Binding fDFreq, Mode=TwoWay}" >
                    <telerik:GridViewDataColumn.Header>
                        <TextBlock Text="Fading Doppler (Hz)" TextAlignment="Center" TextWrapping="Wrap" />
                    </telerik:GridViewDataColumn.Header>
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding fDFreq}" Foreground="{Binding Path, Converter={StaticResource colorConverter}}" IsReadOnly="True" IsEnabled="{Binding Modulation, Converter={StaticResource isModulationOtherThanStatic}}"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                    <telerik:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding fDFreq, Mode=TwoWay}" Foreground="{Binding Path, Converter={StaticResource colorConverter}}" IsEnabled="{Binding Modulation, Converter={StaticResource isModulationOtherThanStatic}}"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate>
                </telerik:GridViewDataColumn>

7 Answers, 1 is accepted

Sort by
0
Ujjwal Lahoti
Top achievements
Rank 1
answered on 10 May 2010, 07:27 PM
Any replies?
0
Nedyalko Nikolov
Telerik team
answered on 12 May 2010, 06:48 PM
Hi Ujjwal Lahoti,

Indeed TextBox handles focus and parent cell cannot become current in order to force commit of the previous edited cell. You can set parent cell as current within TextBox.GotFocus event.

private void TextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            ((UIElement) sender).ParentOfType<GridViewCell>().IsCurrent = true;
        }

Let me know how this works on your end.

Best wishes,
Nedyalko Nikolov
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
Ujjwal Lahoti
Top achievements
Rank 1
answered on 12 May 2010, 09:51 PM
Your sample code works perfectly fine. Thanks for your reply.

I had another question on similar lines.

Currently users have to issue an EditTriggers, to start editing. Requirement for us, is to let user able to start entering data directly, without first issuing the EditTrigger.

eg. In the attached screenshot, the first column is Path, which has a checkbox. To uncheck/check user has to first click on it (where click is a EditTrigger), and then click again to uncheck/check the checkbox. User would like to be able to do it with a single click.

Any suggestions?

The code for the DataGrid is below:

        <telerik:RadGridView x:Name="RadGridView1" Grid.Row="2" 
              ItemsSource="{Binding Source={StaticResource DataSource}, Path=pdpEditorSource}"  
              AutoGenerateColumns="False" HorizontalAlignment="Center"  
              CanUserFreezeColumns="False" ShowGroupPanel="False" IsFilteringAllowed="False" FrozenColumnCount="1" 
              CanUserReorderColumns="False" EditTriggers="CellClick,F2" 
              CellEditEnded="RadGridView_CellEditEnded" CellValidated="RadGridView_CellValidated" BeginningEdit="RadGridView_BeginningEdit"
             
            <telerik:RadGridView.Columns> 
 
                <!-- Path enable/disable colum--> 
                <telerik:GridViewDataColumn Header="Path" TextAlignment="Center"
                    <!-- DataMemberBinding="{Binding Name, Mode=TwoWay}" --> 
                        <telerik:GridViewDataColumn.CellTemplate> 
                        <DataTemplate> 
                            <StackPanel Orientation="Horizontal"
                                <CheckBox IsChecked="{Binding Path}" IsEnabled="False" VerticalAlignment="Center"/> 
                                <Label Foreground="{Binding Path, Converter={StaticResource colorConverter}}"
                                    <!-- Content="{Binding Name}" --> 
                                    <Label.Content> 
                                        <MultiBinding Converter="{StaticResource rowNumberConverter}"
                                            <Binding /> 
                                            <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type telerik:RadGridView}}" /> 
                                        </MultiBinding> 
                                    </Label.Content> 
                                </Label> 
                            </StackPanel> 
                          </DataTemplate> 
                        </telerik:GridViewDataColumn.CellTemplate> 
                        <telerik:GridViewDataColumn.CellEditTemplate> 
                            <DataTemplate> 
                            <StackPanel Orientation="Horizontal"
                                <CheckBox Loaded="Editor_Loaded" Margin="5, 0, 0, 0" VerticalAlignment="Center" IsChecked="{Binding Path, Mode=TwoWay}" /> 
                                <Label Foreground="{Binding Path, Converter={StaticResource colorConverter}}"
                                    <!-- Content="{Binding Name}" --> 
                                    <Label.Content> 
                                        <MultiBinding Converter="{StaticResource rowNumberConverter}"
                                            <Binding /> 
                                            <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type telerik:RadGridView}}" /> 
                                        </MultiBinding> 
                                    </Label.Content> 
                                </Label> 
                            </StackPanel> 
                        </DataTemplate> 
                        </telerik:GridViewDataColumn.CellEditTemplate> 
                    </telerik:GridViewDataColumn> 
 
                <!-- Modulation selection column --> 
                <telerik:GridViewDataColumn Header="Modulation" Width="150" DataMemberBinding="{Binding Modulation, Mode=TwoWay}" TextAlignment="Center" > 
                        <telerik:GridViewDataColumn.CellTemplate> 
                            <DataTemplate> 
                            <TextBlock Text="{Binding Modulation}" Foreground="{Binding Path, Converter={StaticResource colorConverter}}"/> 
                            </DataTemplate> 
                        </telerik:GridViewDataColumn.CellTemplate> 
                        <telerik:GridViewDataColumn.CellEditTemplate > 
                            <DataTemplate> 
                                <StackPanel Orientation="Horizontal"
                                <ComboBox Loaded="Editor_Loaded" Width="100" Margin="5, 0, 0, 0" Foreground="{Binding Path, Converter={StaticResource colorConverter}}" Text="{Binding Modulation, Mode=TwoWay}" Background="White"  SelectionChanged="modulationChanged"
                                        <ComboBoxItem>Static</ComboBoxItem> 
                                        <ComboBoxItem>Rayleigh</ComboBoxItem> 
                                        <ComboBoxItem>Rician</ComboBoxItem> 
                                </ComboBox> 
                                <Button Content="More..." Foreground="{Binding Path, Converter={StaticResource colorConverter}}"/> 
                                </StackPanel> 
                            </DataTemplate> 
                        </telerik:GridViewDataColumn.CellEditTemplate> 
                    </telerik:GridViewDataColumn> 
 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
 


0
Vlad
Telerik team
answered on 13 May 2010, 07:57 AM
Hi,

Why not define this CheckBox directly in CellTemplate instead and mark this column as read-only?

All the best,
Vlad
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
Ujjwal Lahoti
Top achievements
Rank 1
answered on 13 May 2010, 07:38 PM
Thanks for the reply, however I didn't completely follow your suggestion.

The column with the checkbox, has a checkbox and rownumber. I want the user to be able to change it. Read only is not what I want.

Essentially I am asking is that, is there is a way, if user enters a key (number or alphabet) or a mouse press, that is taken as input directly without waiting for the edit trigger.

For checkbox, I want the user to be able to check/uncheck, without first issuing the edit trigger.

Similarly for a textbox, I want to be able to start typing immediately without first issuing edit trigger.


0
Vlad
Telerik team
answered on 14 May 2010, 07:12 AM
Hi,

Indeed if you have all these controls defined in CellTemplate and TwoWay bound you will able to edit your data without putting the cells in edit mode.

Kind regards,
Vlad
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
Ujjwal Lahoti
Top achievements
Rank 1
answered on 17 May 2010, 05:05 PM
Did you mean you will be able to or you will NOT be able to?

If you meant you will be able to, can you tell me how can I start editing the cells without putting them in edit mode?
Tags
GridView
Asked by
Ujjwal Lahoti
Top achievements
Rank 1
Answers by
Ujjwal Lahoti
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Vlad
Telerik team
Share this question
or