Adding GroupDescriptorCollection causes NullReferenceException

5 posts, 0 answers
  1. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 26 Nov 2011 Link to this post

    I am basically just trying to set the default group on a GridView but when I add the GroupDescriptorCollection the app throws a NullReferenceException. I am using a custom data object with defined properties and have also tried it with the DataGrid, same error both ways. How can I set the default grouping on a GridView?

    Thanks!
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 28 Nov 2011 Link to this post

    Hi,

     Have you checked "Grouping" category in our demos?

    Regards,
    Vlad
    the Telerik team

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

  3. DevCraft banner
  4. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 28 Nov 2011 Link to this post

    Hello,

    Thank you for the response. Yes, I have checked those demos which is where I got the code to do this in the first place (From the custom aggregates demo). Here is my grid...

    <telerik:RadGridView x:Name="RadGridViewStopLossDetails" 
                                ItemsSource="{Binding StopLossDetailsGridData}"
                                AutoGenerateColumns="false" ShowGroupPanel="True" FontSize="9"
                                IsFilteringAllowed="False" ShowColumnFooters="True" ShowGroupFooters="True" 
                                Margin="5,10,0,0"
                                Grid.Column="0"
                                Grid.Row="1"
                                VerticalAlignment="Top" 
                                RowIndicatorVisibility="Collapsed"
                                AutoExpandGroups="True"
                            Height="Auto"
                            Width="Auto" HorizontalAlignment="Center">
      
        <telerik:RadGridView.Columns>
      
            <telerik:GridViewDataColumn IsReadOnly="True" Header="Date Requested" DataMemberBinding="{Binding DateRequested}" TextWrapping="wrap" IsVisible="True" UniqueName="DateRequested">
                <telerik:GridViewDataColumn.Footer>
                    <TextBlock Text="Totals:" />
                </telerik:GridViewDataColumn.Footer>
            </telerik:GridViewDataColumn>
      
            <telerik:GridViewDataColumn IsReadOnly="True" Header="Amount Requested:" DataMemberBinding="{Binding AmountRequested}" TextWrapping="NoWrap" DataFormatString="c" >
                <telerik:GridViewDataColumn.AggregateFunctions>
                    <telerik:SumFunction SourceField="AmountRequested" ResultFormatString="{}{0:c}" />
                </telerik:GridViewDataColumn.AggregateFunctions>
            </telerik:GridViewDataColumn>
      
            <telerik:GridViewDataColumn IsReadOnly="True" Header="Date Reimbursed" DataMemberBinding="{Binding DateReimbursed}" TextWrapping="NoWrap" UniqueName="DateReimbursed" />
      
            <telerik:GridViewDataColumn IsReadOnly="True" Header="Amount Reimbursed" DataMemberBinding="{Binding AmountReimbursed}" TextWrapping="NoWrap" DataFormatString="c">
                <telerik:GridViewDataColumn.AggregateFunctions>
                    <telerik:SumFunction SourceField="AmountReimbursed" ResultFormatString="{}{0:c}" />
                </telerik:GridViewDataColumn.AggregateFunctions>
            </telerik:GridViewDataColumn>
      
            <telerik:GridViewDataColumn IsReadOnly="True" Header="% Reimbursed" DataMemberBinding="{Binding PercentReimbursed}" TextWrapping="NoWrap" DataFormatString="{}{0:0%}">
                <telerik:GridViewDataColumn.AggregateFunctions>
                    <telerik:SumFunction SourceField="PercentReimbursed" ResultFormatString="{}{0:0%}" />
                </telerik:GridViewDataColumn.AggregateFunctions>
            </telerik:GridViewDataColumn>
      
        </telerik:RadGridView.Columns>
                      
        <telerik:RadGridView.GroupDescriptors>
            <telerik:ColumnGroupDescriptor Column="{Binding Columns[\DateRequested\], ElementName=RadGridViewStopLossDetails}" SortDirection="Ascending" />
        </telerik:RadGridView.GroupDescriptors>
      
      
    </telerik:RadGridView>
  5. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 29 Nov 2011 Link to this post

    Hi Jfkrueger,

    I've tried to reproduce the problem using the xaml provided and it works fine on my end. You can find my test application attached. Can you give it a try and modify it in order to demonstrate the problem?

    All the best,
    Yordanka
    the Telerik team

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

  6. Joao Paulo Grassi
    Joao Paulo Grassi avatar
    98 posts
    Member since:
    Feb 2011

    Posted 23 Dec 2011 Link to this post

    Hi jfkrueger !

    I don't know if you already solve your issue, i had this same problem once, I always get the NullReference error when the Grid Loads

    The problem in my case are caused by a little mistake, the two columns that i'm using in the GroupDescriptor are binding to properties, but the Name of the properties in XAML are wrong. Because of that the Grid try to group the columns but it just can't because their are null, so theres nothing to group!

    So, when i fix the Binding of the columns all works again perfectly.

    I hope that help you.




Back to Top
DevCraft banner