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

Application crashes when open form has grouped grid and DomainDataSource?

5 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
hvduc
Top achievements
Rank 1
hvduc asked on 13 Dec 2011, 01:05 PM
Hi
I'm using RadGridView control in Rad Controls for telerik Q3 2011 1116 and DomainDataSource control for loading data.
After upgrading application's dll to version Q3 2011 1116, I get this error when open a form with a grid has a grouped column and a DomainDataSource control as form's datacontext.
Error: Unhandled Error in Silverlight Application
Code: 4004   
Category: ManagedRuntimeError      
Message: System.NullReferenceException: Object reference not set to an instance of an object.
   tại Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName, Type memberType)
   tại Telerik.Windows.Data.Expressions.PropertyAccessExpressionBuilder.CreateMemberAccessExpressionOverride()
   tại Telerik.Windows.Data.Expressions.MemberAccessExpressionBuilderBase.CreateMemberAccessExpression()
   tại Telerik.Windows.Controls.GridViewColumn.CreateGroupKeyExpression(ParameterExpression parameterExpression, ExpressionBuilderOptions options)
   tại Telerik.Windows.Controls.GridView.ColumnGroupDescriptor.CreateMemberAccessExpression(ParameterExpression parameterExpression)
   tại Telerik.Windows.Controls.GridView.ColumnGroupDescriptor.CreateGroupKeyExpression(ParameterExpression parameterExpression)
   tại Telerik.Windows.Data.GroupDescriptorBase.CreateGroupKeyExpression(Expression itemExpression)
   tại Telerik.Windows.Data.IGroupDescriptorExtensions.GetGroupKeyType(IGroupDescriptor groupDescriptor, Type itemType)
   tại Telerik.Windows.Data.GroupInfo..ctor(IGroupDescriptor groupDescriptor, Type itemType)
   tại Telerik.Windows.Data.QueryableCollectionViewGroupRoot..ctor(IEnumerable`1 originalGroups, IEnumerable`1 groupDescriptors, IEnumerable`1 sortDescriptors, Type itemType)
   tại Telerik.Windows.Data.QueryableCollectionView.EnsureRootGroup()
   tại Telerik.Windows.Data.QueryableCollectionView.get_Groups()
   tại Telerik.Windows.Controls.GridView.BaseItemsControl.GetEffectiveItems(BaseItemsControl itemsControl)
   tại Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.EnsureIndexTree()
   tại Telerik.Windows.Controls.GridView.GridViewDataControl.InitializeShouldKeepScrollState()
   tại Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsChanged(NotifyCollectionChangedEventArgs e)
   tại Telerik.Windows.Controls.GridView.BaseItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   tại System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   tại Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   tại Telerik.Windows.Data.DataItemCollection.RaiseChangeEvents()
   tại Telerik.Windows.Data.DataItemCollection.SetItemsSource(IEnumerable source)
   tại Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass19.<Bind>b__18()
   tại Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action)
   tại Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(Object newValue)
   tại Telerik.Windows.Controls.GridView.GridViewDataControl.OnApplyTemplate()
   tại System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)

I created a sample project for recreate this error.
In this sample, I add a RadGridView to form, Itemsource binding to DomainDataSource's Data property.

<telerikNavigation:RadWindow x:Class="BusinessApplication1.frmWindow"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
           xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
           xmlns:telerikData="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data"
           xmlns:GridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
                             Width="800" Height="600" MinWidth="800" MinHeight="600"
           >
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
 
        <telerikGridView:RadGridView x:Name="grd"
                                         Grid.Row="0"
                                         ShowGroupPanel="False"
                                         SelectionMode="Single"
                                         RowIndicatorVisibility="Collapsed"
                                         CanUserFreezeColumns="False"
                                         ScrollMode="RealTime"
                                         AutoGenerateColumns="False"
                                         IsReadOnly="True"
                                         ShowColumnFooters="True"
                                         AutoExpandGroups="True"
                                         ItemsSource="{Binding Data}"
                                         IsBusy="{Binding IsLoadingData}"
                                         Margin="8,8,8,0">
            <telerikGridView:RadGridView.Columns>
                <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Column1}"
                                                            Width="0.6*"
                                                            HeaderTextAlignment="Center">
                    <telerikGridView:GridViewDataColumn.Header>
                        <TextBlock HorizontalAlignment="Center"
                                           Text="Column 1" />
                    </telerikGridView:GridViewDataColumn.Header>
                    <telerikGridView:GridViewDataColumn.AggregateFunctions>
                        <telerikData:CountFunction Caption="" />
                    </telerikGridView:GridViewDataColumn.AggregateFunctions>
                    <telerikGridView:GridViewDataColumn.Footer>
                        <GridView:AggregateResultsList ItemsSource="{Binding}"
                                                               VerticalAlignment="Center">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel HorizontalAlignment="Left"
                                                        Margin="4,0"
                                                        Orientation="Horizontal">
                                        <TextBlock VerticalAlignment="Center"
                                                           Text="Row" />
                                        <TextBlock VerticalAlignment="Center"
                                                           Text="{Binding FormattedValue}"
                                                           Margin="4,0,0,0" />
                                    </StackPanel>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Vertical" />
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </GridView:AggregateResultsList>
                    </telerikGridView:GridViewDataColumn.Footer>
                </telerikGridView:GridViewDataColumn>
                <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Column2}"
                                                            Width="0.4*"
                                                            UniqueName="Column2"
                                                            HeaderTextAlignment="Center">
                    <telerikGridView:GridViewDataColumn.Header>
                        <TextBlock HorizontalAlignment="Center"
                                           Text="Column 2" />
                    </telerikGridView:GridViewDataColumn.Header>
                </telerikGridView:GridViewDataColumn>
            </telerikGridView:RadGridView.Columns>
 
        </telerikGridView:RadGridView>
 
    </Grid>
</telerikNavigation:RadWindow>
 
In code-behind, I init a domainDataSource control and group one column of grid by code.
Imports Telerik.Windows.Controls.GridView
Imports Telerik.Windows.Data
Imports Telerik.Windows.Controls
 
Partial Public Class frmWindow
    Inherits RadWindow
    Private m_dss As DomainDataSource
    Public Sub New()
        InitializeComponent()
 
        If grd.GroupDescriptors.Count > 0 Then
            grd.GroupDescriptors.Clear()
        End If
 
        Dim cf As New CountFunction
        Dim descriptor As New ColumnGroupDescriptor
        descriptor.Column = grd.Columns("Column2")
        Me.grd.GroupDescriptors.Add(descriptor)
    End Sub
 
    Private Sub frmWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        m_dss = New DomainDataSource
        Me.DataContext = m_dss
    End Sub
End Class
 
Public Class DemoClass
    Public Property Column1 As String
    Public Property Column2 As String
 
    Public Sub New(m_Column1 As String, m_Column2 As String)
        Column1 = m_Column1
        Column2 = m_Column2
    End Sub
End Class
I debugged when show this form.
When I set DomainDataSource control to form's DataContext, application crashes.

I think there's something wrong with your gridview if it work with DomainDataSource and has a Grouped Column.
How can I fix this error? This error is very critical and I need to fix it soon.
Please reply to me ASAP

5 Answers, 1 is accepted

Sort by
0
Mike
Top achievements
Rank 1
answered on 07 Aug 2012, 03:51 PM
I am getting this same error.  Any fixes?
0
Vlad
Telerik team
answered on 08 Aug 2012, 05:43 AM
Hi,

 Are you using our latest official version Q2 2012 Sp1?

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mike
Top achievements
Rank 1
answered on 08 Aug 2012, 12:38 PM
Nope, I am restricted to using version 2011.2.712.1040 because this is an existing application.
0
Vlad
Telerik team
answered on 09 Aug 2012, 06:19 AM
Hi,

 In this case the only option will be to try to set DataType for the grouped column.

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mike
Top achievements
Rank 1
answered on 16 Aug 2012, 07:12 PM
What event would I attempt to do this in?  SomeGrid_DataLoaded?  Something like this -

 

 

var column = this.SomeGridView.Columns[0] as GridViewBoundColumnBase;

if (column != null)

{

    column.DataTypetypeof(string);

}

Tags
GridView
Asked by
hvduc
Top achievements
Rank 1
Answers by
Mike
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or