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

can new group use inherited groupdescriptor

2 Answers 49 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Ocasio
Top achievements
Rank 2
Veteran
David Ocasio asked on 17 Feb 2011, 03:10 PM
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)
        Else
            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}"  >
       
     <telerik:RadGridView.GroupHeaderTemplate>
         <DataTemplate>
             <Grid>
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="200" />
                     <ColumnDefinition Width="100" />
                     <ColumnDefinition Width="100" />
                     <ColumnDefinition Width="100" />
                     <ColumnDefinition Width="100" />
                 </Grid.ColumnDefinitions>
                 <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" />
             </Grid>
         </DataTemplate>
     </telerik:RadGridView.GroupHeaderTemplate>
     <telerik:RadGridView.Columns>
         <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.Columns>
       
     <telerik:RadGridView.GroupDescriptors >
         <local:SortingGroupDescriptor Member="CustName" SortDirection="Descending" >
             <local:SortingGroupDescriptor.AggregateFunctions >
                 <telerik:SumFunction SourceField="Extended"  ResultFormatString="{} {0:C0}" />
                 <telerik:CountFunction ResultFormatString="{} {0:C0}" />
             </local:SortingGroupDescriptor.AggregateFunctions>
         </local:SortingGroupDescriptor>
     </telerik:RadGridView.GroupDescriptors>
 </telerik:RadGridView>

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

thanks
dco

2 Answers, 1 is accepted

Sort by
0
Accepted
Yavor Georgiev
Telerik team
answered on 17 Feb 2011, 11:03 PM
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.

Regards,
Yavor Georgiev
the Telerik team
0
David Ocasio
Top achievements
Rank 2
Veteran
answered on 18 Feb 2011, 03:21 PM
thanks yavor

that works
dco
Tags
GridView
Asked by
David Ocasio
Top achievements
Rank 2
Veteran
Answers by
Yavor Georgiev
Telerik team
David Ocasio
Top achievements
Rank 2
Veteran
Share this question
or