Hi,
I have a RadGridview that contains a number of data columns and a custom column , which is basically a GridViewDataColumn user control that consists of a textbox and a button. If the user is editing a cell in one of the data column and then immediately clicks on the textbox in the custom column, the pervious cell is still on edit mode and the binding is not committed ( as the way if the user tabs always from the cell). How can I have the other cell updating the target binding if the user click on the texts box within the custom control.
Cheers
4 Answers, 1 is accepted
Would you share a bit more details about the exact implementation of RadGridView and your custom column ? Is there anything specific that needs to be done for reproducing the case ?
Generally, any relevant information and code-snippet would be helpful.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Hi Maya,
Thank you for your reply. Here is a fragment of the code that I am having issue with. I have user control that consists of a text box and a button to show a popup window that display all the text in that field.
<Grid HorizontalAlignment="Stretch" Name="grid1" VerticalAlignment="Top" >
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="15" />
<ColumnDefinition Width="5" />
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="1" Height="23" HorizontalAlignment="Left" Name="btnShow" VerticalAlignment="Top" Width="15" Click="btnShow_Click">
<Image Source="Images\edit.png" HorizontalAlignment="Stretch" />
</Button>
<TextBox Height="23" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" Name="OrgText" VerticalAlignment="Top" LostFocus="OrgText_LostFocus" />
<Popup x:Name="PopupWindow" Width="500" Height="300"
IsOpen="False" AllowsTransparency="True" Placement="Center">
<Border x:Name="bdr1" BorderBrush="Black" BorderThickness="1" Background="#FFF5F3F3" VerticalAlignment="Stretch" CornerRadius="7">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5" Name="grid2" Background="#FFF5F3F3" UseLayoutRounding="True">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="34"/>
<RowDefinition Height="*"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<TextBlock Text="Add note" Grid.Row="0" Margin="5" FontSize="16" x:Name="PoupUpEditorTitle" Grid.ColumnSpan="2"></TextBlock>
<TextBox VerticalAlignment="Stretch" Grid.Row="1"
TextWrapping="Wrap"
AcceptsReturn="True"
VerticalScrollBarVisibility="Visible"
HorizontalAlignment="Stretch" Margin="5" Name="PopUpText" d:LayoutOverrides="HorizontalAlignment"
Grid.ColumnSpan="2" />
<Button Content="Save" Grid.Column="0" Grid.Row="2" Height="23" HorizontalAlignment="Right" Margin="0" Name="btnSave"
VerticalAlignment="Top" Width="75" Click="btnSave_Click"
/>
<Button Content="Cancel" Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="0"
Name="btnCancel" VerticalAlignment="Top" Width="75" Click="btnCancel_Click"
/>
</Grid>
</Border>
</Popup>
</Grid>
A GridViewDataColumn has this user control in its data template. .
<telerik:RadGridView ItemsSource="{Binding Path=Sales}" VerticalAlignment="Top" HorizontalAlignment="Left" ShowColumnFooters="True" AutoGenerateColumns="False"> <telerik:RadGridView.Columns > <telerik:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding Path=SaleOriginPurchased.Quantity}" Width="85" TextAlignment="Right" MaskType="Standard" Mask="999999" > <telerik:GridViewMaskedTextBoxColumn.Header> <TextBlock Text="Number purchased as calves" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" /> </telerik:GridViewMaskedTextBoxColumn.Header> </telerik:GridViewMaskedTextBoxColumn> <telerik:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding Path=SaleOrigin.AvgWeight}" Width="85" TextAlignment="Right" MaskType="Standard" Mask="9999.99"> <telerik:GridViewMaskedTextBoxColumn.Header> <TextBlock Text="Average purchase weight (lb)" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" /> </telerik:GridViewMaskedTextBoxColumn.Header> </telerik:GridViewMaskedTextBoxColumn> <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Description}" Width="*" > <telerik:GridViewColumn.CellTemplate> <DataTemplate> <RmpControls:RmpPopupTextEditor DataContext="{Binding}" MaxLength="500" Text="{Binding Path=Describtion,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Title="Description (Max. 500)" /> </DataTemplate> </telerik:GridViewColumn.CellTemplate> <telerik:GridViewDataColumn.Header> <TextBlock Text="Describtion" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" /> </telerik:GridViewDataColumn.Header> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns> </telerik:RadGridView>
Now when the focus in one of the normal data column, and the user click on the TextBox that is inside the user control, the first cell is still on edit mode and data is not bound to the target. However if I click on another normal data column, the cell works fine. It seems that the user control doesn’t notify the column it got the focus.
Regards
Indeed, in this case when you click on the element in that specific column, the focus is not lost from the previous cell and it stays in edit mode. What you may try is call CommitEdit() method, once the focus goes into that specific UserControl. For example:
XAML:
<
Grid
HorizontalAlignment
=
"Stretch"
Name
=
"grid1"
VerticalAlignment
=
"Top"
GotFocus
=
"grid1_GotFocus"
>
C#:
private void grid1_GotFocus(object sender, RoutedEventArgs e)
{
RadGridView parentGrid = (sender as FrameworkElement).ParentOfType<
RadGridView
>();
parentGrid.CommitEdit();
}
Let me know how this works for you.
Greetings,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
