Hello,
I have a gridview which display workitemdata. The columns are "The client", "The service contract", "The Employee", "The Date", "Hours", "Description", "price hour" and "Value (price hour * hours). The client, service contract and employee are ID value not string.
I have made a three level grouping on Client, service contract and Employee.
I have added a summary row for displaying the total of Value by group and an Handler on GroupSummaryEvaluate for displaying an human readable string instead of ID.
But I'm stuck on these problems:
- I want only to display the subtotal (the summaryRow) on the client group level (last level). The showParentGroupSummaries properties work for each level (true) or the first level (false).
- The GroupSummaryEvaluate handler change the display string of my group header AND my summaryRow.
- What are the options for formatting my summaryRow (like text alignment, font, ...)
- The group sort my values on ID (column value) before grouping. Is there a way to sort on the readable string after the grouping. I could use a numeric enumeration based on my string instead of an ID for grouping. Just asking if there is a kick tip about this :-)
I join two picture (GroupSummaryEvaluate active/not active) and some code.
Imports System.Data.ObjectsImports Telerik.WinControls.UIImports Telerik.WinControls.DataPublic Class View_ValorisationTravail Private _datactx As IconEntities Public ReadOnly Property InnerDataContext As IconEntities Get Return _datactx End Get End Property Private _dataquery As ObjectQuery(Of Travail) Public Property DataQuery As ObjectQuery(Of Travail) Get Return _dataquery End Get Set(value As ObjectQuery(Of Travail)) If _dataquery Is Nothing AndAlso value IsNot Nothing Then _dataquery = value OnDataqueryChanged() End If If Not _dataquery.Equals(value) Then _dataquery = value OnDataqueryChanged() End If End Set End Property Private Sub View_ValorisationTravail_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Me.DesignMode Then _datactx = New IconEntities(GetConnection()) 'Temporaire en attendant les filtres Me.DataQuery = GenerateDataQuery() End If IntitialiseGroupValorisationTravaux(Me.RadGridView1) Dim summaryItem As New GridViewSummaryItem("Valeur", "{0:N2} CHF", GridAggregateFunction.Sum) Dim summaryItemLabel As New GridViewSummaryItem("CHFparheure", "TOTAL", GridAggregateFunction.Sum) Dim summaryRowItem As New GridViewSummaryRowItem() summaryRowItem.Add(summaryItem) summaryRowItem.Add(summaryItemLabel) Me.RadGridView1.SummaryRowsBottom.Add(summaryRowItem) Me.RadGridView1.MasterTemplate.ShowParentGroupSummaries = True End Sub Private Sub OnDataqueryChanged() Me.RadGridView1.DataSource = DataQuery.Execute(MergeOption.OverwriteChanges).ToList End Sub ''' <summary> ''' Generating an ObjectQuery for test purpose ''' </summary> ''' <returns></returns> ''' <remarks></remarks> Private Function GenerateDataQuery() As ObjectQuery(Of Travail) Dim query = From c In _datactx.Travail Select c Return query End Function Private GroupClientDescriptor As GroupDescriptor Private GroupPrestationDescriptor As GroupDescriptor Private GroupCollaborateurDescriptor As GroupDescriptor ''' <summary> ''' Build the group ''' </summary> ''' <param name="aGridView"></param> ''' <remarks></remarks> Private Sub IntitialiseGroupValorisationTravaux(aGridView As RadGridView) aGridView.EnableGrouping = True aGridView.AutoExpandGroups = True aGridView.GroupDescriptors.Clear() Dim SortClientDescriptor As New SortDescriptor("Client", System.ComponentModel.ListSortDirection.Ascending) GroupClientDescriptor = New GroupDescriptor() GroupClientDescriptor.GroupNames.AddRange(New Telerik.WinControls.Data.SortDescriptor() {SortClientDescriptor}) Dim SortPrestationDescriptor As New SortDescriptor("Prestation", System.ComponentModel.ListSortDirection.Ascending) GroupPrestationDescriptor = New GroupDescriptor() GroupPrestationDescriptor.GroupNames.AddRange(New Telerik.WinControls.Data.SortDescriptor() {SortPrestationDescriptor}) Dim SortCollaborateurDescriptor As New SortDescriptor("Collaborateur", System.ComponentModel.ListSortDirection.Ascending) GroupCollaborateurDescriptor = New GroupDescriptor() GroupCollaborateurDescriptor.GroupNames.AddRange(New Telerik.WinControls.Data.SortDescriptor() {SortCollaborateurDescriptor}) aGridView.GroupDescriptors.AddRange(New Telerik.WinControls.Data.GroupDescriptor() {GroupClientDescriptor, GroupPrestationDescriptor, GroupCollaborateurDescriptor}) End Sub Private Sub Travaux_GroupSummaryEvaluate(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GroupSummaryEvaluationEventArgs) Handles RadGridView1.GroupSummaryEvaluate If e.Group.GroupDescriptor.Equals(GroupClientDescriptor) Then If e.Group.ItemCount > 0 AndAlso e.Group.Item(0).DataBoundItem IsNot Nothing Then e.FormatString = CType(e.Group.Item(0).DataBoundItem.Client, Client).Display End If ElseIf e.Group.GroupDescriptor.Equals(GroupPrestationDescriptor) Then If e.Group.ItemCount > 0 AndAlso e.Group.Item(0).DataBoundItem IsNot Nothing Then e.FormatString = CType(e.Group.Item(0).DataBoundItem.Prestation, Prestation).Display End If ElseIf e.Group.GroupDescriptor.Equals(GroupCollaborateurDescriptor) Then If e.Group.ItemCount > 0 AndAlso e.Group.Item(0).DataBoundItem IsNot Nothing Then e.FormatString = CType(e.Group.Item(0).DataBoundItem.ContratEngagement.Collaborateur, Collaborateur).DisplayName End If End If End SubEnd Class