When editing and moving between the columns using TAB, everything works as expected except on the last column, when tab is hit, the cell edited event fires and I can see on debug the data changing but it's only until another row is clicked or you tab all the way through the end of the next row that the data is refreshed.
Is this a known bug?
6 Answers, 1 is accepted
Generally, in scenarios like yours, I would recommend to benefit from the GridViewExpressionColumn. Thus you will not have to handle the CellEditEnded event in order to update the calculated values. Another possible approach would be to perform that calculation in the property itself as illustrated in this blog post.
Still, if those suggestions are not appropriate for you case, please share a bit more details about your project, its settings and the way you handle CellEditEnded event.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Well in this case the 3 columns should be editable and really have a circular reference between them, when one of them is updated, the other 2 recalculate. Can this circular reference be achieved using the Expression columns?
The issue can be reproduced with the attached example. As you can see data is not updated when using tab to move between columns. In my actual scenario I'm using an Entity from EF so the data refreshes everytime except on the last column.
If there's a better way to use the grid to implement this, please let me know or if this is a known bug.
MainPage.xaml:
<UserControl x:Class="RadControlsSilverlightApp1.MainPage" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <Grid x:Name="LayoutRoot" Loaded="LayoutRoot_Loaded"> <telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding RandomProducts}" MinHeight="386" MaxHeight="500" Width="650" CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" CellEditEnded="RadGridView1_CellEditEnded"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn UniqueName="ID" Header="ID" DataMemberBinding="{Binding ID}" IsReadOnly="True" /> <telerik:GridViewDataColumn UniqueName="Name" Header="Name" DataMemberBinding="{Binding Name}" Width="220" IsReadOnly="True"/> <telerik:GridViewDataColumn UniqueName="Data1" Header="Data1" DataMemberBinding="{Binding Data1}" DataFormatString="{}{0:n2}" Width="*" IsReadOnly="True" /> <telerik:GridViewDataColumn UniqueName="Data2" Header="Data2" DataMemberBinding="{Binding Data2}" DataFormatString="{}{0:n2}" Width="*" /> <telerik:GridViewDataColumn UniqueName="Data3" Header="Data3" DataMemberBinding="{Binding Data3}" DataFormatString="{}{0:n2}" Width="*" /> <telerik:GridViewDataColumn UniqueName="Data4" Header="Data4" DataMemberBinding="{Binding Data4}" DataFormatString="{}{0:n2}" Width="*" /> </telerik:RadGridView.Columns> </telerik:RadGridView> </Grid></UserControl>MainPage.xaml.cs:
using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;namespace RadControlsSilverlightApp1{ public class Data { public int ID { get; set; } public string Name { get; set; } public decimal Data1 { get; set; } public decimal Data2 { get; set; } public decimal Data3 { get; set; } public decimal Data4 { get; set; } } public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void RadGridView1_CellEditEnded(object sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e) { string uniqueName = e.Cell.Column.UniqueName; Data item = (Data)e.Cell.ParentRow.Item; switch(uniqueName) { case "Data2": item.Data4 = item.Data1 * (1 + item.Data2 / 100); item.Data3 = item.Data4 - item.Data1; break; case "Data3": item.Data4 = item.Data1 + item.Data3; item.Data2 = (item.Data3 * 100) / item.Data1; break; case "Data4": item.Data3 = item.Data4 - item.Data1; item.Data2 = (item.Data3 * 100) / item.Data1; break; } } private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { List<Data> listOfData = new List<Data>(); for (int i = 0; i < 20; i++) { listOfData.Add(new Data() { ID = i, Name = "Item " + i, Data1 = i, Data2 = i, Data3 = i, Data4 = i }); } RadGridView1.ItemsSource = listOfData; } }}Generally, the GridViewExpressionColumn is not editable, so it may not be appropriate for your specific case. Still, I tried the scenario you described, but I was not able to get the same behavior. May you take a look at the sample attached to verify whether I am missing something ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Indeed it seems in your example the use of OnPropertyChanged makes the difference. Now on my real example what I have as ItemsSource is an IEnumerable collection that comes from a RIAService which ultimately gets the data from an EF connection to SQL. I can't upload .zip files here to show you but I would like to see why is it not working on the case I have.
Thanks,
I just was able to reproduce this issue even with your project. If in your grid you take one of the columns (for example country) and group by it, then edit Number3, then tab, then edit Number and then tab, you won't see your data update. This is the bug I keep running into. Could you please confirm this is a bug and when it will get fixed?
Thanks,
Roberto.
I have tested the sample project provided by Maya but everything works correctly. Please, check this short video and let me know if I have to follow some additional steps to reproduce the issue.
Regards,
Yordanka
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>