This question is locked. New answers and comments are not allowed.
I'm using the custom Telerik.Data.DataTable to bind my grid. I have implemented a custom DateTime sort as follows:
Everything sorts as exepected in the DataTable but the RadGridView never updates to show the new sorting order.
Am I doing something wrong?
protected void CISGrid_Sorting(object sender, GridViewSortingEventArgs e) { Telerik.Data.DataTable table; this.sortingHeaderField = CollectionUtil.GetItemFromCollectionByProperty(this.Layout.HeaderFields, "Description", e.Column.UniqueName) as HeaderField; if (this.sortingHeaderField.Control == HeaderField.ControlType.Date) { table = e.DataControl.ItemsSource as DataTable; if (e.NewSortingState == SortingState.Ascending) { table.Rows.Sort(CompareDatesAscending); e.DataControl.ItemsSource = table; e.Cancel = true; } else if (e.NewSortingState == SortingState.Descending) { table.Rows.Sort(CompareDatesDescending); e.DataControl.ItemsSource = table; e.Cancel = true; } } } private int CompareDatesDescending(DataRow r1, DataRow r2) { return CompareDates(r1, r2, true); } private int CompareDatesAscending(DataRow r1, DataRow r2) { return CompareDates(r1, r2, false); } private int CompareDates(DataRow r1, DataRow r2, bool descending) { DateTime dateTime1; DateTime dateTime2; DateTime.TryParseExact(r1[this.sortingHeaderField.Description].ToString(), this.sortingHeaderField.InputFormat, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime1); DateTime.TryParseExact(r2[this.sortingHeaderField.Description].ToString(), this.sortingHeaderField.InputFormat, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime2); if (descending) { return DateTime.Compare(dateTime1, dateTime2); } else { return DateTime.Compare(dateTime2, dateTime1); } }Everything sorts as exepected in the DataTable but the RadGridView never updates to show the new sorting order.
Am I doing something wrong?