Problem with hidden aggregate columns

7 posts, 0 answers
  1. Earnest
    Earnest avatar
    6 posts
    Member since:
    Aug 2008

    Posted 25 Sep 2011 Link to this post

    After updating to q2 2011 sp1 we are having a problem (didn't happen before). I have included source below to illustrate the problem. It is very similar to one scenario in our app. If you hit the load button two times you get a crash upon clicking the second time with a null reference exception. This only happens if you hide the column with the aggregate before the load. If you comment out that line, it doesn't crash. In our scenario, the user may have hidden some of the columns, including some that have aggregates.

    We've had to comment out all aggregate columns to get around this, which is not pleasing our clients. Any suggestion? Thanks.

    <UserControl
        x:Class="TestGrid.MainPage"
        <Grid
            x:Name="LayoutRoot"
            Background="White">
            <Grid.RowDefinitions>
                <RowDefinition
                    Height="Auto" />
                <RowDefinition />
                <RowDefinition
                    Height="Auto" />
            </Grid.RowDefinitions>
            <Button
                Click="Button_Click"
                Content="Load" />
            <telerik:RadGridView
                x:Name="grid"
                Grid.Row="1"
                AutoGenerateColumns="False"
                ShowColumnFooters="True">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn
                        DataMemberBinding="{Binding Name}" />
                    <telerik:GridViewDataColumn
                        DataMemberBinding="{Binding Quantity}">
                        <telerik:GridViewDataColumn.AggregateFunctions>
                            <telerik:SumFunction
                                Caption="Total:" />
                        </telerik:GridViewDataColumn.AggregateFunctions>
                    </telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
            <telerik:RadDataPager
                x:Name="pageCtrl"
                Grid.Row="2" />
        </Grid>
    </UserControl>
    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;
    using System.Collections.ObjectModel;
     
    namespace TestGrid
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
            }
     
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                LoadData();
            }
     
            private void LoadData()
            {
                // comment out this line and you can click the button as many times as you'd like
                // but with it uncommented you can only click it it once and it crashes on the second click
                if(grid.Columns[1].IsVisible) grid.Columns[1].IsVisible = false;
     
                var widgets = new List<Widget>();
                for (int i = 0; i < 10; i++)
                {
                    widgets.Add(new Widget() { Name = string.Format("Widget {0}", i), Quantity = 1 });
                }
     
                pageCtrl.Source = widgets;
                grid.ItemsSource = pageCtrl.PagedSource;
            }
        }
     
        public class Widget
        {
            public string Name { get; set; }
            public int Quantity { get; set; }
        }
    }
  2. Heiko Görig
    Heiko Görig avatar
    23 posts
    Member since:
    Jun 2012

    Posted 26 Sep 2011 Link to this post

    We have the same problem. This is the full stack trace:

    System.NullReferenceException:  Object reference not set to an instance of an object. Telerik.Windows.Controls.GridView.AggregatesToGroupFooterAggregatesConverter.<>c__DisplayClass4.<Convert>b__1(AggregateResult f)
    System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
    MS.Internal.EnumerableCollectionView.LoadSnapshotCore(IEnumerable source)
    MS.Internal.EnumerableCollectionView.LoadSnapshot(IEnumerable source)
    MS.Internal.EnumerableCollectionView.RefreshOverride()
    System.Windows.Data.CollectionView.Refresh()
    Telerik.Windows.Controls.GridView.GridViewFooterCell.AggregateResults_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
    System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
    Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
    Telerik.Windows.Data.RadObservableCollection`1.ResumeNotifications()
    Telerik.Windows.Controls.GridView.GridViewDataControl.CreateAggregateResults()
    Telerik.Windows.Controls.GridView.GridViewDataControl.CalculateAggregates()
    Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
    System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
    Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
    Telerik.Windows.Data.DataItemCollection.OnCollectionViewCollectionChanged(NotifyCollectionChangedEventArgs e)
    Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs e)
    Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
    Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
    Telerik.Windows.Data.QueryableCollectionView.RefreshOverride()
    Telerik.Windows.Data.QueryableCollectionView.RefreshInternal()
    Telerik.Windows.Data.QueryableCollectionView.RefreshOrDefer()
    Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChanged(NotifyCollectionChangedEventArgs args)
    Telerik.Windows.Data.QueryableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
    Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
    Telerik.Windows.Data.QueryableCollectionView.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
    Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
    System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
    Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
    Telerik.Windows.Data.RadObservableCollection`1.ResumeNotifications()



    Please fix this asap.
  3. DevCraft banner
  4. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 27 Sep 2011 Link to this post

    Same problems here.
  5. Edward Pauley
    Edward Pauley avatar
    48 posts
    Member since:
    May 2010

    Posted 27 Sep 2011 Link to this post

    I am also experienced that Error. If I increase the Width of my radWindow which will covers all of the columns of the radgridview(having aggregate columns), then everything works perfectly. However, if i shrink my radwindow's width a little which will hide some aggregate columns, then the error appears for loading new data.

  6. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 28 Sep 2011 Link to this post

    Hello,

    The exception is already resolved and the fix for it will be part of the latest internal build (next Monday).
     
    Best wishes,
    Yordanka
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  7. Maurizio
    Maurizio avatar
    3 posts
    Member since:
    Aug 2008

    Posted 26 Oct 2011 Link to this post

    Same error, I downloaded the build 2011.2.1026.1040 but dll telerik.windows.control is missed, then i got the error:

    Error 1 Assembly 'Telerik.Windows.Controls.GridView, Version=2011.2.1026.1040, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' uses 'Telerik.Windows.Controls, Version=2011.2.1026.1040, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' which has a higher version than referenced assembly 'Telerik.Windows.Controls, Version=2011.2.920.1040, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' c:\Program Files (x86)\Telerik\RadControls for Silverlight Q1 2011 SP1\Binaries\Silverlight\Telerik.Windows.Controls.GridView.dll FMSControls2
  8. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 27 Oct 2011 Link to this post

    Hello Maurizio,

    I've just tested the latest internal build and no problem occurs. Can you send us a sample project showing the exception? You need to open a support ticket and attach it there. Thank you.
     
    Best wishes,
    Yordanka
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner