Getting an error while using ColumnGroupDescriptor in RadGridView in WPF

7 posts, 0 answers
  1. Vinod
    Vinod avatar
    5 posts
    Member since:
    Nov 2011

    Posted 19 Nov 2011 Link to this post

    Hello Guys....I am getting an error while using ColumnGroupDescriptor in XAML,  to make a group based on some column....
    if i do not use the following code in my xaml then it is working nicely and that code is:-

    <telerik:RadGridView.GroupDescriptors>
                    <telerik:ColumnGroupDescriptor Column="{Binding Columns[\PresentationName\], ElementName=telrikDataGrid}" SortDirection="Ascending" />
                </telerik:RadGridView.GroupDescriptors>


    As i am using the above code the it showing a green underline...and showing a error as:
    " NullReferenceException was thrown on "ColumnGroupDescriptor": Object reference not set to an instance of an object. " 

    please guide me where i amm going wrong...please help me out ASAP.....Thank you guys...

    i am also sending my project. So please find it as attachment.

    Thanks!!!!!1
    <Window x:Class="DataGridLoadingTest.MainWindow"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
            xmlns:local="clr-namespace:DataGridLoadingTest"
            xmlns:s="clr-namespace:System;assembly=mscorlib"
            xmlns:telerikData="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data"
            Title="MainWindow" Height="350" Width="600">
         
        <Window.Resources>
     
            <!--<src:BoolToVisiblityConverter x:Key="bool2vis"/>-->
            
     
        </Window.Resources>
         
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="20"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
             
           
              <Button Grid.Row="0"  Content="LoadData" Click="LaodData_Click" HorizontalAlignment="Right"/>
         
            <telerik:RadGridView x:Name="telrikDataGrid" Grid.Row="1" ShowColumnFooters="True" ShowGroupFooters="True"
                                         AlternateRowBackground="Azure" AlternationCount="2" AutoGenerateColumns="False"
                                         IsReadOnly="True">
     
     
                <telerik:RadGridView.Columns>
     
                    <telerik:GridViewDataColumn Header="ID" DataMemberBinding="{Binding PresentationID}">
                        <telerik:GridViewDataColumn.AggregateFunctions>
                            <telerik:CountFunction Caption="Total Rows"/>
                        </telerik:GridViewDataColumn.AggregateFunctions>
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="PresentationPath" DataMemberBinding="{Binding PresentationPath}" >
                    </telerik:GridViewDataColumn>
     
     
                    <telerik:GridViewDataColumn Header="PresentationName" DataMemberBinding="{Binding PresentationName}" >
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="StratTime" DataMemberBinding="{Binding StartTime}">
                    </telerik:GridViewDataColumn>
     
     
                    <telerik:GridViewDataColumn Header="EndTime" DataMemberBinding="{Binding EndTime}">
                    </telerik:GridViewDataColumn>
     
     
                    <telerik:GridViewDataColumn Header="Duration(Sec)" DataMemberBinding="{Binding Duration}">
                        
                        <telerik:GridViewDataColumn.AggregateFunctions>
                            <telerik:SumFunction SourceFieldType="{x:Type s:Int64}" ResultFormatString="{}{0:d}" Caption="Total Duration: " SourceField="Duration"/>
                        </telerik:GridViewDataColumn.AggregateFunctions>
             
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="LogLevel" DataMemberBinding="{Binding LogLevel}">
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="Mode" DataMemberBinding="{Binding Mode}">
                    </telerik:GridViewDataColumn>  
                     
                </telerik:RadGridView.Columns>
     
                <telerik:RadGridView.GroupDescriptors>
     
                    <telerik:ColumnGroupDescriptor Column="{Binding Columns[\PresentationName\], ElementName=telrikDataGrid}" SortDirection="Ascending" />
                </telerik:RadGridView.GroupDescriptors>
                 
                 
            </telerik:RadGridView>
     
        </Grid>
    </Window>
    <Window x:Class="DataGridLoadingTest.MainWindow"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
            xmlns:local="clr-namespace:DataGridLoadingTest"
            xmlns:s="clr-namespace:System;assembly=mscorlib"
            xmlns:telerikData="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data"
            Title="MainWindow" Height="350" Width="600">
         
        <Window.Resources>
     
            <!--<src:BoolToVisiblityConverter x:Key="bool2vis"/>-->
            
     
        </Window.Resources>
         
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="20"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
             
           
              <Button Grid.Row="0"  Content="LoadData" Click="LaodData_Click" HorizontalAlignment="Right"/>
         
            <telerik:RadGridView x:Name="telrikDataGrid" Grid.Row="1" ShowColumnFooters="True" ShowGroupFooters="True"
                                         AlternateRowBackground="Azure" AlternationCount="2" AutoGenerateColumns="False"
                                         IsReadOnly="True">
     
     
                <telerik:RadGridView.Columns>
     
                    <telerik:GridViewDataColumn Header="ID" DataMemberBinding="{Binding PresentationID}">
                        <telerik:GridViewDataColumn.AggregateFunctions>
                            <telerik:CountFunction Caption="Total Rows"/>
                        </telerik:GridViewDataColumn.AggregateFunctions>
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="PresentationPath" DataMemberBinding="{Binding PresentationPath}" >
                    </telerik:GridViewDataColumn>
     
     
                    <telerik:GridViewDataColumn Header="PresentationName" DataMemberBinding="{Binding PresentationName}" >
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="StratTime" DataMemberBinding="{Binding StartTime}">
                    </telerik:GridViewDataColumn>
     
     
                    <telerik:GridViewDataColumn Header="EndTime" DataMemberBinding="{Binding EndTime}">
                    </telerik:GridViewDataColumn>
     
     
                    <telerik:GridViewDataColumn Header="Duration(Sec)" DataMemberBinding="{Binding Duration}">
                        
                        <telerik:GridViewDataColumn.AggregateFunctions>
                            <telerik:SumFunction SourceFieldType="{x:Type s:Int64}" ResultFormatString="{}{0:d}" Caption="Total Duration: " SourceField="Duration"/>
                        </telerik:GridViewDataColumn.AggregateFunctions>
             
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="LogLevel" DataMemberBinding="{Binding LogLevel}">
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="Mode" DataMemberBinding="{Binding Mode}">
                    </telerik:GridViewDataColumn>  
                     
                </telerik:RadGridView.Columns>
     
                <telerik:RadGridView.GroupDescriptors>
                    <!--Here i am getting an error..i mean in the given line as " Object reference not set to an instance of an object.    "-->
                    <telerik:ColumnGroupDescriptor Column="{Binding Columns[\PresentationName\], ElementName=telrikDataGrid}" SortDirection="Ascending" />
                </telerik:RadGridView.GroupDescriptors>
                 
                 
            </telerik:RadGridView>
     
        </Grid>
    </Window>
     
     
                    <telerik:GridViewDataColumn Header="EndTime" DataMemberBinding="{Binding EndTime}">
                    </telerik:GridViewDataColumn>
     
     
                    <telerik:GridViewDataColumn Header="Duration(Sec)" DataMemberBinding="{Binding Duration}">
                        
                        <telerik:GridViewDataColumn.AggregateFunctions>
                            <telerik:SumFunction SourceFieldType="{x:Type s:Int64}" ResultFormatString="{}{0:d}" Caption="Total Duration: " SourceField="Duration"/>
                        </telerik:GridViewDataColumn.AggregateFunctions>
             
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="LogLevel" DataMemberBinding="{Binding LogLevel}">
                    </telerik:GridViewDataColumn>
     
                    <telerik:GridViewDataColumn Header="Mode" DataMemberBinding="{Binding Mode}">
                    </telerik:GridViewDataColumn>  
                     
                </telerik:RadGridView.Columns>
     
                <telerik:RadGridView.GroupDescriptors>
     
                    <telerik:ColumnGroupDescriptor Column="{Binding Columns[\PresentationName\], ElementName=telrikDataGrid}" SortDirection="Ascending" />
                </telerik:RadGridView.GroupDescriptors>
                 
                 
            </telerik:RadGridView>
     
        </Grid>
    </Window>
  2. Stephen
    Stephen avatar
    24 posts
    Member since:
    May 2011

    Posted 02 Dec 2011 Link to this post

    I'm having the exact same problem in Silverlight. Please help.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 05 Dec 2011 Link to this post

    Hi,

     Unfortunately we are out of ideas what can cause this. A sample project where the problem can be reproduced will help us.

    Best wishes,
    Vlad
    the Telerik team

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

  5. Licenses
    Licenses avatar
    10 posts
    Member since:
    Sep 2011

    Posted 29 Mar 2012 Link to this post

    I have the same error!! Help
  6. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 30 Mar 2012 Link to this post

    Hi,

    Unfortunately we are out of ideas what can cause this. A sample project where the problem can be reproduced will help us. 

    All the best,
    Ross
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  7. Licenses
    Licenses avatar
    10 posts
    Member since:
    Sep 2011

    Posted 03 Apr 2012 Link to this post

    I solved, but using the index of the column, the column apparently can not be found by name or syntax that you indicate. (Columns [\ ColName \])

    <telerik:ColumnGroupDescriptor Column="{Binding Columns[0], ElementName=Grid1}"/>
  8. Fredy
    Fredy avatar
    7 posts
    Member since:
    Mar 2012

    Posted 24 Nov 2012 Link to this post

    Add UniqueName

    <telerik:GridViewDataColumn Header="PresentationName" DataMemberBinding="{Binding PresentationName}" UniqueName="PresentationName"  >
                    </telerik:GridViewDataColumn>
Back to Top
UI for WPF is Visual Studio 2017 Ready