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

RadGridView BeginEdit() changing current row

1 Answer 94 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 08 Mar 2011, 06:19 PM
I have a column with a celltemplate and celleditingtemplate with a bound checkbox (in order to allow the user to click once to edit). I would like to get the row into edit mode at the same time. So in the checkbox click event I am attempting this, but the current row of the grid changes to the next row and it does not enter edit mode. If I set a break point on BeginEdit() to delay its execution then it works. I tried to use Dispatcher.BeginInvoke for the BeginEdit call, but that is not working. Here is a snippet:

                <telerik:GridViewDataColumn Header="Active" EditTriggers="CellClick">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox HorizontalAlignment="Center" Click="CheckBox_Click" IsChecked="{Binding Active, Mode=TwoWay}" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                    <telerik:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
                            <CheckBox HorizontalAlignment="Center" IsChecked="{Binding Active, Mode=TwoWay}" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate>
                </telerik:GridViewDataColumn>


        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            var cb = sender as CheckBox;
            var r = cb.ParentOfType<GridViewRow>();
            var c = cb.ParentOfType<GridViewCell>();
            r.IsSelected = true;

            this.Dispatcher.BeginInvoke(() =>
            {
                grd.BeginEdit();
            });
        }

Marty

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 11 Mar 2011, 05:05 PM
Hi Martin,

I have prepared an example project that proposes a possible solution to your case. You will need to set the IsHitTestVisible property of the CheckBox thus disabling it from getting the focus. Furthermore, you may set the EditTriggers property of the column to CellClick and Default. 
Please, refer to the sample project and let us know, if it fits into your requirements.


Kind regards,
Ivan Ivanov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Martin
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or