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

Edit All Columns When GridViewRow IsInEditMode is True

6 Answers 246 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rebecca
Top achievements
Rank 1
Rebecca asked on 14 Nov 2012, 08:20 PM
Hi,

I would like display the editing controls for all of the columns in a GridViewRow when the GridViewRow is in edit mode.

I have tried handling the RadGridView's BeginningEdit, PreparedCellForEdit, and PrepairingCellFor events to set every cell's InEditMode=True; however, it only ever shows one cell in edit mode.

For example, it seems like the following accomplishes nothing at any point in the edit life cycle for the RadGridView:
Dim row As Telerik.Windows.Controls.GridView.GridViewRow = DirectCast(e.Row, Telerik.Windows.Controls.GridView.GridViewRow)
 
For Each cell As Telerik.Windows.Controls.GridView.GridViewCell In row.Cells
    If Object.Equals(cell.Column, e.Column) = False Then
      cell.IsInEditMode = True
    End If
Next


I also tried using DataTriggers on the GridViewCell to accomplish this like so:
<Style TargetType="telerik:GridViewCell">
    <Style.Triggers>
        <DataTrigger Binding="{Binding Path=IsInEditMode, RelativeSource={RelativeSource AncestorType={x:Type telerik:GridViewRow}}}" Value="True">
            <Setter Property="Foreground" Value="Aqua" />
            <Setter Property="IsInEditMode" Value="True" />
        </DataTrigger>
    </Style.Triggers>
</Style>

This sets the foreground for all of the cells in the row when the row is in edit mode, however only 1 cell displays the edit controls even though I have set the IsInEditMode to true for every cell if the row is in edit mode. Not only that, but the cell that is displaying the controls for editing isn't the one that I double clicked on, but is the cell to the right of it.

I have tried a few other approaches but none of them have been successful.

I look forward to hearing back to you on how to accomplish this.

Thank you,

-Rebecca

6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 15 Nov 2012, 09:59 AM
Hi Rebecca,

Your code does not seem to work as it is not possible more than one cell to be in mode EditMode. This is by design. Why do you need to have all the cells in the row in edit mode at the same time?

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Rebecca
Top achievements
Rank 1
answered on 15 Nov 2012, 07:57 PM
Thank you for your reply.

It is a request from the client that we make this change.

They complained that the grid is confusing to use because they do not know which columns are editable and which are not.

They do not like the idea of showing the editing controls at all times because they say it is too overwhelming.

So we came up with the idea that when the row was in edit mode, all of the columns that can be edited will show controls for editing; much like how the GridViews in ASP.NET show all of the editing controls when a row is in edit mode.

I understand that this is a big request, but, I would really appreciate a means to make the client happy and take advantage of your GridView's other capabilities.

-Rebecca
0
Dimitrina
Telerik team
answered on 16 Nov 2012, 12:01 PM
Hello Rebecca,

I understand your point but this would not be possible as only one cell could be in edit more at a time. I would suggest you to apply a proper style for the columns that are not editable. That way the client can distinguish the editable cells from the not editable ones. 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Steve
Top achievements
Rank 1
answered on 21 Nov 2012, 04:08 PM
Rebecca,

I have been struggling with the same problem and have found the best way round it is using the CellTemplare on the column, the only potential problem is if your gird has lots of row/columns then performance can be adversely affected but it's worth trying.

Great avatar by the way, you can't go wrong with anything cat related !
0
Vikas
Top achievements
Rank 1
answered on 21 Mar 2014, 03:13 PM
 <Style TargetType="{x:Type telerik:GridViewRow}">
                
                <Style.Triggers>
                    <DataTrigger Binding="{Binding InEditMode, Mode=TwoWay}" Value="true">
                        <Setter Property="IsInEditMode" Value="True"/>
                        
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
            <Style TargetType="{x:Type telerik:GridViewCell}">
                
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsInEditMode, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:GridViewRow}}}" Value="true">
                        <Setter Property="IsInEditMode" Value="True"/>
                        <Setter Property="Background" Value="Orange"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
0
Vikas
Top achievements
Rank 1
answered on 21 Mar 2014, 03:14 PM
InEditMode is my Class property which is bind to Each Row of the Grid.

 <Style TargetType="{x:Type telerik:GridViewRow}">
                
                <Style.Triggers>
                    <DataTrigger Binding="{Binding InEditMode, Mode=TwoWay}" Value="true">
                        <Setter Property="IsInEditMode" Value="True"/>
                        
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
            <Style TargetType="{x:Type telerik:GridViewCell}">
                
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsInEditMode, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:GridViewRow}}}" Value="true">
                        <Setter Property="IsInEditMode" Value="True"/>
                        <Setter Property="Background" Value="Orange"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
Tags
GridView
Asked by
Rebecca
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Rebecca
Top achievements
Rank 1
Steve
Top achievements
Rank 1
Vikas
Top achievements
Rank 1
Share this question
or