can new group use inherited groupdescriptor

3 posts, 1 answers
  1. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 17 Feb 2011 Link to this post

    i am using your example code for sorting groups by an aggregate function

    Public Class SortingGroupDescriptor
        Inherits groupdescriptor
        Public Overrides Function CreateGroupSortExpression(ByVal groupingExpression As System.Linq.Expressions.Expression) As System.Linq.Expressions.Expression
            If Me.AggregateFunctions.Count = 0 Then
                Return MyBase.CreateGroupSortExpression(groupingExpression)
                Return Me.AggregateFunctions(0).CreateAggregateExpression(groupingExpression)
            End If
        End Function
    End Class
    <telerik:RadGridView  Grid.Row="1" IsReadOnly="True" x:Name="gridInventory" AutoGenerateColumns="False" EditTriggers="None" ShowGroupFooters="False" GroupRowStyle="{StaticResource MyCustomGroupRowStyle}"  >
                         <ColumnDefinition Width="200" />
                         <ColumnDefinition Width="100" />
                         <ColumnDefinition Width="100" />
                         <ColumnDefinition Width="100" />
                         <ColumnDefinition Width="100" />
                     <TextBlock Text="{Binding Header}"    Grid.Column="0" Margin="4,0,0,0" TextAlignment="Left" VerticalAlignment="Center" />
                     <TextBlock Text="Extended:" Grid.Column="1" TextAlignment="Right" Margin="0,0,4,0" />
                     <TextBlock Text="{Binding AggregateResults[0].Value,StringFormat=\{0:c0\}}"   Grid.Column="2" Margin="4,0,0,0" TextAlignment="Right" VerticalAlignment="Center" />
                     <TextBlock Text="Count:" Grid.Column="3" TextAlignment="Right" Margin="0,0,4,0"  />
                     <TextBlock Text="{Binding AggregateResults[1].Value}"   Grid.Column="4" Margin="4,0,0,0" TextAlignment="Right" VerticalAlignment="Center" />
             <telerik:GridViewDataColumn DataMemberBinding="{Binding CustName}" Header="Customer" UniqueName="CustName" />
             <telerik:GridViewDataColumn DataMemberBinding="{Binding Z_No}" Header="Part#" />
             <telerik:GridViewDataColumn DataMemberBinding="{Binding NameManf}" Header="Manufacturer" />
             <telerik:GridViewDataColumn DataMemberBinding="{Binding ManfNo}" Header="Manf#" />
             <telerik:GridViewDataColumn DataMemberBinding="{Binding ZDesc}" Header="Description" />
             <telerik:GridViewDataColumn DataMemberBinding="{Binding QtyOnHand}" Header="Qty"  TextAlignment="Right" />
             <telerik:GridViewDataColumn DataMemberBinding="{Binding Cost}" Header="Cost"  TextAlignment="Right" DataFormatString="{} {0:c6}" />
             <telerik:GridViewDataColumn DataMemberBinding="{Binding Extended}" Header="Extended" DataFormatString="{} {0:c0}"  TextAlignment="Right"  />
             <telerik:GridViewDataColumn Header="Customer Count" TextAlignment="Right" DataMemberBinding="{Binding custcount}" />
             <telerik:GridViewDataColumn DataMemberBinding="{Binding NameCommodity}" Header="Commodity" />
         <telerik:RadGridView.GroupDescriptors >
             <local:SortingGroupDescriptor Member="CustName" SortDirection="Descending" >
                 <local:SortingGroupDescriptor.AggregateFunctions >
                     <telerik:SumFunction SourceField="Extended"  ResultFormatString="{} {0:C0}" />
                     <telerik:CountFunction ResultFormatString="{} {0:C0}" />

    Unfortunatly if the user removes the group i set up in xaml to choose there own group
    the  type of descriptor added is not the one i indicated in xaml

    so the sorting of the groups is lost

    is there anyway to pass my inherited class when the group is started ...
    i tried the event "grouping" but the groupdescriptor propery is readonly

  2. Answer
    Yavor Georgiev
    Yavor Georgiev avatar
    982 posts

    Posted 17 Feb 2011 Link to this post

    Hello David Ocasio,

     In the Grouping event, you can cancel the grouping operation (e.Cancel = True) so that the group descriptor in the GroupDescriptor property is not added. You then create an instance of your own IGroupDescriptor implementation and add it to the RadGridView.

    Yavor Georgiev
    the Telerik team
  3. DevCraft R3 2016 release webinar banner
  4. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 18 Feb 2011 Link to this post

    thanks yavor

    that works
Back to Top