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

Automatic begin to edit cell in the next column

1 Answer 168 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nikita
Top achievements
Rank 1
Nikita asked on 23 Jul 2018, 01:53 PM

Hi!

I need to implementation auto start begin edit cell in the same row and next column, after click in previous column.
In begin my table, code works correctly. But in the last row and in penultimate column code doesn't work correctly, it begin start edit in the last row and in third column.
But after how I write value by myself, code start to work correctly. I use telerik framework.
Thank you for your responses!

var element = sender as FrameworkElement;
        ConditionsRadGridView.CommitEdit();
        var parentCell = element.GetVisualParent<GridViewCell>();
        if (parentCell != null)
        {
            var index = ConditionsRadGridView.Columns.IndexOf(parentCell.Column);
            if (index != -1 && index < parentCell.ParentRow.Cells.Count)
            {
                var nextCell = parentCell.ParentRow.Cells[index] as GridViewCell;
                if (nextCell != null)
                {
                    ConditionsRadGridView.CurrentCellInfo = new GridViewCellInfo(nextCell);
                    ConditionsRadGridView.BeginEdit();
                }
            }
        }
<telerik:RadGridView ValidatesOnDataErrors="InViewMode"                      
                     Name="ConditionsRadGridView"
                     Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
                     Margin="6 3 6 6" HorizontalAlignment="Left"
                     RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False"
                     CanUserDeleteRows="False" CanUserInsertRows="False" ShowGroupPanel="False" CanUserReorderColumns="False"
                     FrozenColumnCount="1"
                     CanUserFreezeColumns="False"
                     ItemsSource="{Binding Conditions}" EnableColumnVirtualization="False"
                     RowStyle="{StaticResource ValidationFixStyle}"
                     SelectionMode="Extended" 
                     cal:Message.Attach="[Event PreviewKeyUp] = [Action ConditionsKeyUp($this.SelectedItems, $eventArgs)]">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn CellStyle="{StaticResource SelectedCellStyle}" Header="{x:Static properties:Resources.Station}" DataMemberBinding="{Binding Name, Mode=TwoWay}"
                                CellTemplateSelector="{StaticResource ConditionNameTemplateSelector}"/>
                <telerik:GridViewColumn IsVisible="{Binding IsHaveGroups}">
                <telerik:GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox Visibility="{Binding IsGroup, Converter={StaticResource BoolToVisibilityConverter}}" IsChecked="{Binding IsSplitUp, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                  cal:Message.Attach="[Event Click] = [Action IsSplitUpClick($datacontext)]" />
                    </DataTemplate>
                </telerik:GridViewColumn.CellTemplate>
            </telerik:GridViewColumn>
    <telerik:GridViewDataColumn Header="{x:Static properties:Resources.AffinityOperator}" ColumnGroupName="Affinity"
                                    DataMemberBinding="{Binding AffinityOperator, UpdateSourceTrigger=PropertyChanged}" TextAlignment="Center" IsReadOnly="True">
          <telerik:GridViewDataColumn.CellTemplate>
            <DataTemplate DataType="{x:Type vm:StationConditionViewModel}">
              <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <controls3:RadComboBox IsEnabled="{Binding IsRowEnabled}" SelectionChanged="StartEditNextCell"
                                       SelectedItem="{Binding AffinityOperator, UpdateSourceTrigger=PropertyChanged}"
                                       ItemsSource="{Binding Operators}" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>
                </Grid>
            </DataTemplate>
          </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
    <telerik:GridViewDataColumn Header="{x:Static properties:Resources.AffinityValue}" ColumnGroupName="Affinity" IsReadOnlyBinding="{Binding AffinityIsReadOnly}"
                                     DataMemberBinding="{Binding Path=AffinityValue}" TextAlignment="Right">
      <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate DataType="{x:Type vm:StationConditionViewModel}">
          <TextBlock Text="{Binding AffinityValue, StringFormat={}{0:N2}}" Visibility="{Binding AffinityVisibility}" VerticalAlignment="Center" HorizontalAlignment="Right" />
        </DataTemplate>
      </telerik:GridViewDataColumn.CellTemplate>
    </telerik:GridViewDataColumn>

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 26 Jul 2018, 12:23 PM
Hello Nikita,

Can you tell me where the code that calls the BeginEdit() (the first code snippet) is executed? On what event and who calls it? Also, can you send me some drawings of a video that describes what is the expected behavior. I am asking this because I am not sure that I understand properly your requirement.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
General Discussions
Asked by
Nikita
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or