This is a migrated thread and some comments may be shown as answers.

Problem with hidden aggregate columns

6 Answers 151 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Earnest
Top achievements
Rank 1
Earnest asked on 26 Sep 2011, 03:47 AM
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; }
    }
}

6 Answers, 1 is accepted

Sort by
0
Heiko Görig
Top achievements
Rank 1
answered on 26 Sep 2011, 09:19 AM
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.
0
danparker276
Top achievements
Rank 2
answered on 27 Sep 2011, 06:39 PM
Same problems here.
0
Edward Pauley
Top achievements
Rank 1
answered on 27 Sep 2011, 10:35 PM
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.

0
Yordanka
Telerik team
answered on 28 Sep 2011, 08:05 AM
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 >>

0
Maurizio
Top achievements
Rank 1
answered on 26 Oct 2011, 05:17 PM
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
0
Yordanka
Telerik team
answered on 27 Oct 2011, 09:08 AM
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 >>

Tags
GridView
Asked by
Earnest
Top achievements
Rank 1
Answers by
Heiko Görig
Top achievements
Rank 1
danparker276
Top achievements
Rank 2
Edward Pauley
Top achievements
Rank 1
Yordanka
Telerik team
Maurizio
Top achievements
Rank 1
Share this question
or