or
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 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 // // radPageViewPage_Template // // TODO: Code generation for '' failed because of Exception 'Invalid Primitive Type: System.IntPtr. Consider using CodeObjectCreateExpression.'. this.radPageViewPage_Template.Controls.Add(this.radGridView_PlanTemplates); this.radPageViewPage_Template.Location = new System.Drawing.Point(10, 37); this.radPageViewPage_Template.Name = "radPageViewPage_Template"; this.radPageViewPage_Template.Size = new System.Drawing.Size(307, 502); this.radPageViewPage_Template.Text = "Templates";
private void dg_CustomerContact_CellMouseMove(object sender, MouseEventArgs e) { GridDataCellElement cell = this.dg_CustomerContact.RootElement.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement; if (cell != null && ((GridViewDataColumn)cell.ColumnInfo).Name == "dg_TalkedWith_col_Email") { originalCursor = this.dg_CustomerContact.Cursor; this.dg_CustomerContact.Cursor = Cursors.Hand; } else { if (originalCursor != null) { this.dg_CustomerContact.Cursor = originalCursor; originalCursor = Cursors.Default; } } }