Hi,
We are creating columns dynamically. There are a few datetime columns where we set the datatype as DateTime and CellEditTemplate as below.
dataColumn.DataType = (typeof(DateTime?));
dataColumn.DataFormatString = "{0:dd-MMM-yyyy}";
dataColumn.TextAlignment = TextAlignment.Right;
dataColumn.CellEditTemplate = GetDatePickerTemplate(dataColumn);
}
private static DataTemplate GetDatePickerTemplate(GridViewDataColumn column)
{
var fef = new FrameworkElementFactory(typeof(FormatedRadDatePicker));
................
The issue is when you sort the grid with this datetime column and try to edit any value in this column the application crashes with below error:
Dispatcher UnHandled Exception: System.ArgumentException: Object must be of type DateTime.
at System.DateTime.CompareTo(Object value)
at Telerik.Windows.Data.FunctionComparer.Compare(Object x, Object y)
at Telerik.Windows.Data.ListExtensions.BinarySearch[T](IList`1 items, T value, Func`3 compareFunc)
at Telerik.Windows.Data.KeyedCollection.IndexOf(Object value)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.RefreshAlternation(GridViewDataControl parentGrid, GridViewRow gridViewRow, Object dataItem)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.RealizeRows(Int32 startIndex, Int32 endIndex, Double& verticalOffset, HashSet`1& realizedRows)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.MeasureOverride(Size availableSize)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)...........
To me it looks like after the cell edit is over grid tries to put the newly edited data to its rightful place based on sortdescriptor. Probably it fetches the data from DateTimeTextProperty as string type and is not able to compare with DateTime values of other cells....
We are creating columns dynamically. There are a few datetime columns where we set the datatype as DateTime and CellEditTemplate as below.
dataColumn.DataType = (typeof(DateTime?));
dataColumn.DataFormatString = "{0:dd-MMM-yyyy}";
dataColumn.TextAlignment = TextAlignment.Right;
dataColumn.CellEditTemplate = GetDatePickerTemplate(dataColumn);
}
private static DataTemplate GetDatePickerTemplate(GridViewDataColumn column)
{
var fef = new FrameworkElementFactory(typeof(FormatedRadDatePicker));
................
The issue is when you sort the grid with this datetime column and try to edit any value in this column the application crashes with below error:
Dispatcher UnHandled Exception: System.ArgumentException: Object must be of type DateTime.
at System.DateTime.CompareTo(Object value)
at Telerik.Windows.Data.FunctionComparer.Compare(Object x, Object y)
at Telerik.Windows.Data.ListExtensions.BinarySearch[T](IList`1 items, T value, Func`3 compareFunc)
at Telerik.Windows.Data.KeyedCollection.IndexOf(Object value)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.RefreshAlternation(GridViewDataControl parentGrid, GridViewRow gridViewRow, Object dataItem)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.RealizeRows(Int32 startIndex, Int32 endIndex, Double& verticalOffset, HashSet`1& realizedRows)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.MeasureOverride(Size availableSize)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)...........
To me it looks like after the cell edit is over grid tries to put the newly edited data to its rightful place based on sortdescriptor. Probably it fetches the data from DateTimeTextProperty as string type and is not able to compare with DateTime values of other cells....