RadGridView Startup Grouping Exception

11 posts, 0 answers
  1. Frank
    Frank avatar
    27 posts
    Member since:
    May 2011

    Posted 15 Jul 2011 Link to this post

    Hello Telerik-Community,

    when i set a GroupDescriptor (equal at Code-Behind or Xaml), get a NullReferenzException.

    Here the Stacktrace:
    {System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
       bei Telerik.Windows.Data.TypeExtensions.DefaultValue(Type type)
       bei Telerik.Windows.Data.Expressions.ExpressionFactory.DefaltValueExpression(Type type)
       bei Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName, Type memberType)
       bei Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName, Type memberType, Boolean liftMemberAccessToNull)
       bei Telerik.Windows.Data.Expressions.PropertyAccessExpressionBuilder.CreateMemberAccessExpressionOverride()
       bei Telerik.Windows.Data.Expressions.MemberAccessExpressionBuilderBase.CreateMemberAccessExpression()
       bei Telerik.Windows.Data.GroupDescriptor.CreateGroupKeyExpression(ParameterExpression parameterExpression)
       bei Telerik.Windows.Data.GroupDescriptorBase.CreateGroupKeyExpression(Expression itemExpression)
       bei Telerik.Windows.Data.IGroupDescriptorExtensions.GetGroupKeyLambda(IGroupDescriptor groupDescriptor, Type itemType)
       bei Telerik.Windows.Data.IGroupDescriptorExtensions.GetGroupSortKeyFunction(IGroupDescriptor groupDescriptor, Type itemType)
       bei Telerik.Windows.Data.QueryableCollectionView.InitializeInternalList(IQueryable view)
       bei Telerik.Windows.Data.QueryableCollectionView.CreateInternalList()
       bei Telerik.Windows.Data.QueryableCollectionView.EnsureInternalList()
       bei Telerik.Windows.Data.QueryableCollectionView.get_InternalList()
       bei Telerik.Windows.Data.QueryableCollectionView.EnsureRootGroup()
       bei Telerik.Windows.Data.QueryableCollectionView.get_Groups()
       bei Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.PrepareGrouping()
       bei Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.ResetGeneratorAndReuseContainers()
       bei Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.ReInitializeContainers()
       bei Telerik.Windows.Controls.GridView.GridViewDataControl.ReuseContainersOnReset()
       bei Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsChanged(NotifyCollectionChangedEventArgs e)
       bei Telerik.Windows.Controls.GridView.BaseItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       bei System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       bei Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       bei Telerik.Windows.Data.DataItemCollection.OnCollectionViewCollectionChanged(NotifyCollectionChangedEventArgs e)
       bei Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs e)
       bei Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       bei Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       bei Telerik.Windows.Data.QueryableCollectionView.RefreshOverride()
       bei Telerik.Windows.Data.QueryableCollectionView.RefreshInternal()
       bei Telerik.Windows.Data.QueryableCollectionView.RefreshOrDefer()
       bei Telerik.Windows.Data.QueryableCollectionView.InvalidatePagingAndRefresh()
       bei Telerik.Windows.Data.QueryableCollectionView.OnGroupDescriptorsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       bei System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       bei System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       bei Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       bei Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       bei System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       bei Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
       bei System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)
       bei System.Collections.ObjectModel.Collection`1.System.Collections.IList.Insert(Int32 index, Object value)
       bei Telerik.Windows.Data.CollectionHelper.Insert(IList target, IEnumerable newItems, Int32 startingIndex, IEqualityComparer itemComparer)
       bei Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(IList sender, NotifyCollectionChangedEventArgs args)
       bei Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
       bei Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       bei System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       bei System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       bei Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       bei Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       bei System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       bei Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
       bei System.Collections.ObjectModel.Collection`1.Add(T item)
       bei MMPortalSL.View.LM_Overview.ContentControl_Loaded(Object sender, RoutedEventArgs e)
       bei MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
       bei MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)}

    I using the Q2 2011.

    Regards,
    Christian
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Jul 2011 Link to this post

    Hi Christian,

     I have tested adding a GroupDescriptor (using version Q2 2011) and the Grouping is working fine. I have a collection of Clubs, each club has a "Name" property. This is the code I have used:

    public MainPage()
           {
               InitializeComponent();
               GroupDescriptor descriptor = new GroupDescriptor();
               descriptor.Member = "Name";
               clubsGrid.GroupDescriptors.Add(descriptor);
           }

    May you please check if you have set the descriptor.Name appropriately? Otherwise could you, please, specify how is your data represented and how do you set the GroupDescriptor?

    All the best,
    Didie
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Frank
    Frank avatar
    27 posts
    Member since:
    May 2011

    Posted 20 Jul 2011 Link to this post

    Hi Didie,

    here my code:
    GroupDescriptor descriptorBook = new GroupDescriptor();
    descriptorHersteller.Member = "BookID";
    descriptorHersteller.DisplayContent = "Book";
    descriptorHersteller.SortDirection = ListSortDirection.Ascending;
    GridView.GroupDescriptors.Add(descriptorBook);
    BookID is a property of my Class.

    I Set the GroupDescriptor at Control_Loaded Event of the User Control.
    But when I set the GroupDescriptor in the construktor or directly in xaml, get the Exception.

    Regards,
    Christian
  4. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2477 posts

    Posted 20 Jul 2011 Link to this post

    Hello Christian,

    Have you by any chance set the DataLoadMode to Asynchronous?

    Is it possible to send us a very small dummy project that reproduces this exception?

    Regards,
    Ross
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  5. Gio
    Gio avatar
    6 posts
    Member since:
    Jul 2011

    Posted 29 Nov 2012 Link to this post

    I Have same problem:

       su Telerik.Windows.Data.IGroupDescriptorExtensions.GetGroupSortKeyFunction(IGroupDescriptor groupDescriptor, Type itemType)
       su Telerik.Windows.Data.QueryableCollectionView.InitializeInternalList(IQueryable view)
       su Telerik.Windows.Data.QueryableCollectionView.CreateInternalList()
       su Telerik.Windows.Data.QueryableCollectionView.EnsureInternalList()
       su Telerik.Windows.Data.QueryableCollectionView.get_InternalList()
       su Telerik.Windows.Data.QueryableCollectionView.EnsureRootGroup()
       su Telerik.Windows.Data.QueryableCollectionView.get_Groups()
       su Telerik.Windows.Controls.GridView.BaseItemsControl.GetEffectiveItems(BaseItemsControl itemsControl)
       su Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.EnsureIndexTree()
       su Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.get_IndexTree()
       su Telerik.Windows.Controls.GridView.GridViewDataControl.InitializeShouldKeepScrollState()
       su Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsChanged(NotifyCollectionChangedEventArgs e)
       su Telerik.Windows.Controls.GridView.BaseItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       su System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       su Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       su Telerik.Windows.Data.DataItemCollection.OnCollectionViewCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       su Telerik.Windows.Data.Listener`2.ReceiveWeakEvent(Object sender, TArgs args)
       su Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       su Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       su Telerik.Windows.Data.QueryableCollectionView.RefreshOverride()
       su Telerik.Windows.Data.QueryableCollectionView.RefreshInternal()
       su Telerik.Windows.Data.QueryableCollectionView.RefreshOrDefer()
       su Telerik.Windows.Data.QueryableCollectionView.InvalidatePagingAndRefresh()
       su Telerik.Windows.Data.QueryableCollectionView.OnGroupDescriptorsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       su System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       su System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       su Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       su Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       su System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       su Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
       su System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)
       su System.Collections.ObjectModel.Collection`1.System.Collections.IList.Insert(Int32 index, Object value)
       su Telerik.Windows.Data.CollectionHelper.Insert(IList target, IEnumerable newItems, Int32 startingIndex, IEqualityComparer itemComparer)
       su Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(IList sender, NotifyCollectionChangedEventArgs args)
       su Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
       su Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       su System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       su System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       su Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       su Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       su System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       su Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
       su System.Collections.ObjectModel.Collection`1.Add(T item)
       su Eusoft.Client.Controls.FixFilterAndGroup.rgv_DataLoaded(Object sender, EventArgs e)
       su Telerik.Windows.Controls.GridView.GridViewDataControl.OnDataLoaded(EventArgs e)
       su Telerik.Windows.Controls.GridView.GridViewDataControl.LoadData()
       su Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       su System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       su Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       su Telerik.Windows.Data.DataItemCollection.ClearItemsSource()
       su Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass14.<Bind>b__13()
       su Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action)
       su Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(Object newValue)
       su Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsSourceChanged(Object oldValue, Object newValue)
       su Telerik.Windows.Controls.DataControl.OnItemsSourcePropertyChanged(DependencyObject origin, DependencyPropertyChangedEventArgs args)
       su Telerik.Windows.PropertyMetadata.PropertyChangeHook.OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       su System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       su System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       su System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
       su System.Windows.Data.BindingExpression.SendDataToTarget()
       su System.Windows.Data.BindingExpression.SourcePropertyChanged(PropertyPathListener sender, PropertyPathChangedEventArgs args)
       su System.Windows.PropertyPathListener.ReconnectPath()
       su System.Windows.Data.Binding.EnsureBreakPoint(BindingDebugState debugState, Action callback, Boolean canDelay)
       su System.Windows.Data.BindingExpression.OnSourcePropertyChanging(Action action)
       su System.Windows.PropertyPathListener.RaisePropertyPathStepChanged(PropertyPathStep source)
       su System.Windows.PropertyAccessPathStep.RaisePropertyPathStepChanged(PropertyListener source)
       su System.Windows.CLRPropertyListener.SourcePropertyChanged(Object sender, PropertyChangedEventArgs args)
       su System.Windows.Data.WeakPropertyChangedListener.PropertyChangedCallback(Object sender, PropertyChangedEventArgs args)
       su System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
     su xx.ApplicationModel.NotifyPropertyChanged(String propertyName)


    I set the group on load of grid:
    private  private GroupDescriptorCollection _groupDescriptor;

    void rgv_DataLoaded(object sender, System.EventArgs e)
            {
                RadGridView grid = sender as RadGridView;
                if (grid.GroupDescriptors.Count == 0 && _groupDescriptor.Count > 0)
                {
                    foreach (var g in _groupDescriptor)
                    {
                        grid.GroupDescriptors.Add(g);
                    }
                }
            }


    and i have this exception on set of datacontext.

    Thanks

  6. Gio
    Gio avatar
    6 posts
    Member since:
    Jul 2011

    Posted 29 Nov 2012 Link to this post

    While if i set SortDirection = null it does not throw exception.
    But i lose the order of group.

     void rgv_DataLoaded(object sender, System.EventArgs e)
            {
                RadGridView grid = sender as RadGridView;
                if (grid.GroupDescriptors.Count == 0 && _groupDescriptor.Count > 0)
                {
                    foreach (var g in _groupDescriptor)
                    {
                        g.SortDirection = null;
                        grid.GroupDescriptors.Add(g);
                    }
                }
            }


    Thanks again.
  7. Vanward
    Vanward avatar
    6 posts
    Member since:
    Dec 2010

    Posted 18 Feb 2013 Link to this post

    Hello.
    Today I ran into so-and-same problem.
    How to eradicate it?
  8. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 18 Feb 2013 Link to this post

    Hello,

    May I ask you to isolate the problem in a sample project so that we could check the behavior locally? You can go through a blog post on how to create it here.

    All the best,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  9. Vanward
    Vanward avatar
    6 posts
    Member since:
    Dec 2010

    Posted 18 Feb 2013 Link to this post

    Hello.
    I found the problem.
    We used the modified component DataTable, which I found in your blog.
    This component implements the IEnumerable.
    So, the problem is that if a component is initialized empty DataTable used to ItemsSource, then adding a new GroupDescriptor with the set value SortDirection an exception (Null reference).
    If we use _internalView directly, this exception does not occur.
    I created ticket #660882
  10. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 19 Feb 2013 Link to this post

    Hello,

    Thank you for the provided sample project. We will further investigate the case.

    Greetings,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  11. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 19 Feb 2013 Link to this post

    Hello,

    You got the exception, because the type of the column can not be resolved as there are not any items added to the DataTable. Please set a proper DataType for the GridViewDataColumn and the issue will be resoved:

    var gridColumn = new GridViewDataColumn { DataMemberBinding = newBinding(reportColumn.Name), Header = reportColumn.Name, DataType=typeof(object) };
     

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top