I just want to make sure I'm doing this correctly. In my constructor I have this:
HamsGrid.MasterTemplate.SortComparer = new HamsCustomComparer();
That works as expected. Now I also want the user to be able to sort individual columns if they so choose, so I added two radio buttons to the screen, one called Default the other User. When User is clicked I want to clear the custom comparer, so I do this:
HamsGrid.MasterTemplate.SortComparer = null; //line 1807 in code
Then, of course in the Default handler I have:
HamsGrid.MasterTemplate.SortComparer = new HamsCustomComparer();
Setting it to null is causing an exception (I only have from my call at line 1807 on up):
System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Collections.Generic.AvlTree`1.LastIndex(ValueT value)
at Telerik.Collections.Generic.AvlTree`1.InsertWithDuplicates(ValueT value)
at Telerik.Collections.Generic.AvlTree`1.Add(ValueT item)
at Telerik.WinControls.Data.AvlIndex`1.Perform()
at Telerik.WinControls.Data.AvlIndex`1.get_Items()
at Telerik.WinControls.Data.RadDataView`1.get_Items()
at Telerik.WinControls.Data.RadCollectionView`1.GetEnumerator()
at Telerik.WinControls.UI.GridViewInfo.Refresh()
at Telerik.WinControls.UI.GridViewInfo.get_ChildRows()
at Telerik.WinControls.UI.GridViewTemplate.get_ChildRows()
at Telerik.WinControls.UI.ViewInfoTraverser.SetCollectionForStage(Boolean initializeCollection)
at Telerik.WinControls.UI.ViewInfoTraverser.SetCollectionForStage()
at Telerik.WinControls.UI.ViewInfoTraverser.ChangeCollectionForward()
at Telerik.WinControls.UI.ViewInfoTraverser.MoveNextCore()
at Telerik.WinControls.UI.ViewInfoTraverser.MoveNext()
at Telerik.WinControls.UI.GridTraverser.MoveNextCore()
at Telerik.WinControls.UI.GridTraverser.MoveNext()
at Telerik.WinControls.UI.ItemScroller`1.UpdateScrollRange()
at Telerik.WinControls.UI.RowScroller.UpdateScrollRange()
at Telerik.WinControls.UI.GridTableElement.UpdateNoDataText()
at Telerik.WinControls.UI.GridTableElement.UpdateAll()
at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
at Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
at Telerik.WinControls.UI.GridViewEventProcessEntity.Process(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI)
at Telerik.WinControls.UI.GridViewTemplate.DispatchEvent(GridViewEvent gridEvent, Boolean postUI)
at Telerik.WinControls.UI.GridViewTemplate.DispatchDataViewChangedEvent(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
at Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(DataViewChangedEventArgs e)
at Telerik.WinControls.UI.GridViewTemplate.CollectionView_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at Telerik.WinControls.Data.RadCollectionView`1.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify)
at Telerik.WinControls.Data.RadDataView`1.RefreshOverride()
at Telerik.WinControls.Data.RadDataView`1.OnNotifyPropertyChanged(PropertyChangedEventArgs e)
at Telerik.WinControls.Data.RadDataView`1.set_Comparer(IComparer`1 value)
at Telerik.WinControls.UI.GridViewTemplate.set_SortComparer(IComparer`1 value)
at TCS.TDOC.DispatchScreen.SortCustomRadio_ToggleStateChanged(Object sender, StateChangedEventArgs args) in C:\Work\TCS\Source\TCS\TCS\ContentScreens\DispatchScreen.cs:line 1807
HamsGrid.MasterTemplate.SortComparer = new HamsCustomComparer();
That works as expected. Now I also want the user to be able to sort individual columns if they so choose, so I added two radio buttons to the screen, one called Default the other User. When User is clicked I want to clear the custom comparer, so I do this:
Then, of course in the Default handler I have:
HamsGrid.MasterTemplate.SortComparer = new HamsCustomComparer();
System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Collections.Generic.AvlTree`1.LastIndex(ValueT value)
at Telerik.Collections.Generic.AvlTree`1.InsertWithDuplicates(ValueT value)
at Telerik.Collections.Generic.AvlTree`1.Add(ValueT item)
at Telerik.WinControls.Data.AvlIndex`1.Perform()
at Telerik.WinControls.Data.AvlIndex`1.get_Items()
at Telerik.WinControls.Data.RadDataView`1.get_Items()
at Telerik.WinControls.Data.RadCollectionView`1.GetEnumerator()
at Telerik.WinControls.UI.GridViewInfo.Refresh()
at Telerik.WinControls.UI.GridViewInfo.get_ChildRows()
at Telerik.WinControls.UI.GridViewTemplate.get_ChildRows()
at Telerik.WinControls.UI.ViewInfoTraverser.SetCollectionForStage(Boolean initializeCollection)
at Telerik.WinControls.UI.ViewInfoTraverser.SetCollectionForStage()
at Telerik.WinControls.UI.ViewInfoTraverser.ChangeCollectionForward()
at Telerik.WinControls.UI.ViewInfoTraverser.MoveNextCore()
at Telerik.WinControls.UI.ViewInfoTraverser.MoveNext()
at Telerik.WinControls.UI.GridTraverser.MoveNextCore()
at Telerik.WinControls.UI.GridTraverser.MoveNext()
at Telerik.WinControls.UI.ItemScroller`1.UpdateScrollRange()
at Telerik.WinControls.UI.RowScroller.UpdateScrollRange()
at Telerik.WinControls.UI.GridTableElement.UpdateNoDataText()
at Telerik.WinControls.UI.GridTableElement.UpdateAll()
at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
at Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
at Telerik.WinControls.UI.GridViewEventProcessEntity.Process(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI)
at Telerik.WinControls.UI.GridViewTemplate.DispatchEvent(GridViewEvent gridEvent, Boolean postUI)
at Telerik.WinControls.UI.GridViewTemplate.DispatchDataViewChangedEvent(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e)
at Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(DataViewChangedEventArgs e)
at Telerik.WinControls.UI.GridViewTemplate.CollectionView_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at Telerik.WinControls.Data.RadCollectionView`1.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify)
at Telerik.WinControls.Data.RadDataView`1.RefreshOverride()
at Telerik.WinControls.Data.RadDataView`1.OnNotifyPropertyChanged(PropertyChangedEventArgs e)
at Telerik.WinControls.Data.RadDataView`1.set_Comparer(IComparer`1 value)
at Telerik.WinControls.UI.GridViewTemplate.set_SortComparer(IComparer`1 value)
at TCS.TDOC.DispatchScreen.SortCustomRadio_ToggleStateChanged(Object sender, StateChangedEventArgs args) in C:\Work\TCS\Source\TCS\TCS\ContentScreens\DispatchScreen.cs:line 1807