Ticket Q273195
Visible to All Users

Custom Group Summaries

created 15 years ago

I have a grid that the user can choose to populate with up to 17 columns. They can also choose to group by any of the selected columns. My grid is torn down and rebuilt from scratch in code each time the user changes their column and grouping selection. Reading through the knowledge base and other peoples questions I have managed to get group footer summaries working. What I can not quite get to work is custom text on the group summary. I have attached a picture of what I have achieved so far, and what I would like to achieve. Lets say you have category and that category has three sub-categories. I can get the group summary to say "sub-category1, sub-category2, sub-category3" but when drop back to the category level, it displays sub-categoty3 in the summary?
This is the code I am using to build my custom group summary on the fly;
        Dim item1 As GridGroupSummaryItem = New GridGroupSummaryItem()
        item1.FieldName = ProductionView.Columns(0).FieldName
        item1.SummaryType = DevExpress.Data.SummaryItemType.Custom
        item1.ShowInGroupColumnFooter = ProductionView.Columns(0)
        item1.Tag = "Process Me"
        ProductionView.GroupSummary.Add(item1)
And this is the code I use to process the group summary;
    Private Sub ProductionView_CustomSummaryCalculate(ByVal sender As Object, ByVal e As DevExpress.Data.CustomSummaryEventArgs) Handles ProductionView.CustomSummaryCalculate
        If e.SummaryProcess = DevExpress.Data.CustomSummaryProcess.Finalize AndAlso (CType(e.Item, GridGroupSummaryItem)).Tag.Equals("Process Me") Then
            e.TotalValue = (TryCast(sender, GridView)).GetGroupRowValue(e.RowHandle)
        End If
    End Sub
I know it's probably not the way this should be done, but it's the best I could do using the learn as you go approach.
Can you see were I am going wrong? Am I approaching this all wrong? I have read, and read through the articles on this site but cant figure out it is that I am not doing right?

Show previous comments (2)
DevExpress Support Team 15 years ago

    Hi Marcus,
    Thank you for the response. Indeed, it seems that we didn't completely understand your requirements. Please modify the gridView1_CustomSummaryCalculate method of example E307 as follows:

    C#
    private void gridView1_CustomSummaryCalculate(object sender, DevExpress.Data.CustomSummaryEventArgs e) { GridView gv = (GridView)sender; if (!e.IsGroupSummary) return; if (e.SummaryProcess == DevExpress.Data.CustomSummaryProcess.Finalize && Equals(((GridGroupSummaryItem)e.Item).Tag, 1)) { e.TotalValue = gv.GetGroupRowValue(e.RowHandle, gv.GroupedColumns[e.GroupLevel]); } }
    Visual Basic
    Private Sub gridView1_CustomSummaryCalculate(ByVal sender As Object, ByVal e As DevExpress.Data.CustomSummaryEventArgs) Dim gv As GridView = CType(sender, GridView) If (Not e.IsGroupSummary) Then Return If e.SummaryProcess = DevExpress.Data.CustomSummaryProcess.Finalize AndAlso Equals((CType(e.Item, GridGroupSummaryItem)).Tag, 1) Then e.TotalValue = gv.GetGroupRowValue(e.RowHandle, gv.GroupedColumns(e.GroupLevel)) End If End Sub

    To left-align the footer cell contents, set the GridView.Appearance.GroupFooter.TextOptions.HAlignment property to Near.
    Please let us know if this helps.
    Thanks,
    Michael.

      Thanks very much for the reply. The result was excellent, exactly what I was after.
      Now that issue can be put to rest.
      I have attached a picture of another and hopefully the last issue I am having with the grid.
      I am not sure though whether I should create another Question or not?
      Anyway, as you will see in the picture, my grid is on the left and a preview of the grid is on the right.
      The preview is create using a componentlink printpreview dialgog in ribbon mode.
      The preview does not align the group footers left.
      But the main problem really, is the merged cells are way wrong.
      merging seems to happen for two rows max then it unmerges and merges another two, then unmerges does another two etc etc
      Any ideas?
      Thanks again for the previous help it was excellent.

      DevExpress Support Team 15 years ago

        Hi Marcus,
        To left-align a group footer text in a printed document, set the GridView.AppearancePrint.GroupFooter.TextOptions.HAlignment property to Near, and set the GridView.OptionsPrint.UsePrintStyles property to True.
        As for the cell merging issue, I'm afraid I can't reproduce it on my side. I've attached a sample project that works fine for me. Please modify it to reproduce the issue, and attach it to your next post.
        Thanks,
        Michael.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.