Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
850
Sumaries in groupbyrows
posted

Hello,

I want to use GroupByRows in my ultrawingrid. The structure of the table that Im using is diplayed in the image that I attached.

So, I need that my group by rows show me the total of meters for each zone and for each subzone too, exaxcly as shown  in the picture.

what can I do?

Any suggestions, I'll be very grateful

Help me please.

 

 

  • 850
    posted

    Hi Mike, I  change my code

    With DisplayFormat = "Total of meters = {0}"  I don't need all this anymore

            'Dim s As String = e.Row.DescriptionWithSummaries
            'Dim posicion As Integer = InStr(s, "=")
            'Dim total As String = Mid(s, posicion + 1, s.Length)

     

     

    So I changed my InitializeGroupByRow code and add in InitializeLayout

            summary.DisplayFormat = "Total of meters = {0}"

     

    Private Sub UltraGrid1_InitializeGroupByRow(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeGroupByRowEventArgs) Handles UltraGrid1.InitializeGroupByRow
            If e.Row.Column.Key = "zone" Then
                e.Row.Appearance.BackColor = Color.Purple
                e.Row.Description = "Zone : " & e.Row.Value.ToString() & ", Total of Subzones : " & e.Row.Rows.Count
            End If
            If e.Row.Column.Key = "Subzone" Then
                e.Row.Appearance.BackColor = Color.Tomato
                e.Row.Description = "Subzone : " & e.Row.Value.ToString() & ", Total of rows : " & e.Row.Rows.Count
            End If

        End Sub

     

    and the only problem now is that in my groupbyrows appears the name of the source column To Summarize.

     

    How can I remove it?

     

  • 850
    posted

    Sorry for my mistakes,

    Public Class SummaryGroupByRow

       Private Sub UltraGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout

            Dim columnToSummarize As UltraGridColumn = e.Layout.Bands(0).Columns("mts")
            Dim summary As SummarySettings = e.Layout.Bands(0).Summaries.Add("Total", SummaryType.Sum, columnToSummarize)
            summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right
            e.Layout.Override.SummaryDisplayArea = Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.InGroupByRows


        End Sub

        Private Sub SummaryGroupByRow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            UltraDataSource1.Band.Columns.Add("zone", GetType(String))
            UltraDataSource1.Band.Columns.Add("Subzone", GetType(String))
            UltraDataSource1.Band.Columns.Add("mts", GetType(Integer))

            UltraDataSource1.Rows.Add(New Object() {"A", "101", 200})
            UltraDataSource1.Rows.Add(New Object() {"A", "101", 200})
            UltraDataSource1.Rows.Add(New Object() {"A", "102", 200})
            UltraDataSource1.Rows.Add(New Object() {"A", "102", 200})
            UltraDataSource1.Rows.Add(New Object() {"B", "103", 200})
            UltraDataSource1.Rows.Add(New Object() {"B", "103", 200})
            UltraDataSource1.Rows.Add(New Object() {"B", "104", 200})
            UltraDataSource1.Rows.Add(New Object() {"B", "104", 200})
            UltraDataSource1.Rows.Add(New Object() {"B", "104", 200})


            Me.UltraGrid1.DataSource = Me.UltraDataSource1


            UltraGrid1.DisplayLayout.Bands(0).SortedColumns.Add("zone", False, True)
            UltraGrid1.DisplayLayout.Bands(0).SortedColumns.Add("Subzone", False, True)

        End Sub

        Private Sub UltraGrid1_InitializeGroupByRow(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeGroupByRowEventArgs) Handles UltraGrid1.InitializeGroupByRow

        'Here, I try to get only the value of the grand total for each groupbyrow
        'I mean, I get of the e.Row.DescriptionWithSummaries the string "subzone : 101 (2 items) mts Sum = 400") for example.
        'Of that string I need only the last part, the grand total for each groupbyrow ("400" for the example above)
        'I don´t know if there is a simplest solution for this part, I don´t know, but I need the only grand total
        'for my custom text.

        Dim defaultTextGrooupByRow As String = e.Row.DescriptionWithSummaries
            Dim position As Integer = InStr(defaultTextGrooupByRow, "=")
            Dim total As String = Mid(s, position + 1, defaultTextGrooupByRow.Length)

       
       
            If e.Row.Column.Key = "zone" Then
                e.Row.Appearance.BackColor = Color.Purple
                e.Row.Description = "Zone : " & e.Row.Value.ToString() & ", Total of zonas : " & e.Row.Rows.Count & "    Total of meters: " & total
            End If

        'In This part I set my custom text.
            'For example  changing this "subzone : 101 (2 items) mts Sum = 400" for "Subzone : 101 Total of subzones 2 Total of meters: 400"
            'and so on for the others groupbyrows.

            If e.Row.Column.Key = "Subzone" Then
                e.Row.Appearance.BackColor = Color.Tomato
                e.Row.Description = "Subzone : " & e.Row.Value.ToString() & ", Total of Subzones : " & e.Row.Rows.Count & "    Total of meters: " & total
            End If

        End Sub


    so, without using InitializeGroupByRow, my ultragrid shows the gropbyrows using the default Description text and the grand totals too(Image 1).
    If I use InitializeGroupByRow, to change default description for each groupbyrow, they change it for my custom text, but "[Column_name] sum "[Grand total]", example "mts sum : 400"
    appears with along my custom text and I Need only my custom text in my groupbyrows without "[Column_name] sum "[Grand total]" because in my custom description text I'm including the grand total.

    Maybe "[Column_name] sum "[Grand total]" has its own way to chage it for a custom text. I don´t know

    Is there a way to do this?
    Is there a simple way to do this? maybe I'm trying do this with a wrong way

    I tried this

    change

    Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.InGroupByRows

    to

    Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.None

    But the total of meters not appears anymore in my custom text

     

  • 850
    posted

    Hi Mike,

    sorry to bother you again, I didn´t realize about this behavior in my group by rows
    when I change the title  by  a custom text
    (using InitializeGroupByRow event), default summary caption  is displayed with along the custom text. I only  want to show my custom text  in the group by rows.
    How can I do this?

    In the image that Im attaching, I try to describe what i want. I hope explaining myself  well.

    This is the code that Im using:

     Private Sub UltraGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout

      Dim columnToSummarize As UltraGridColumn = e.Layout.Bands(0).Columns("mts")
            Dim summary As SummarySettings = e.Layout.Bands(0).Summaries.Add("Total", SummaryType.Sum, columnToSummarize)
            summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right
            e.Layout.Override.SummaryDisplayArea = Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.InGroupByRows
        End Sub

    Private Sub UltraGrid1_InitializeGroupByRow(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeGroupByRowEventArgs) Handles UltraGrid1.InitializeGroupByRow
           
            Dim s As String = e.Row.DescriptionWithSummaries
            Dim posicion As Integer = InStr(s, "=")
            Dim total As String = Mid(s, posicion + 1, s.Length)

            If e.Row.Column.Key = "zone" Then
                e.Row.Appearance.BackColor = Color.Purple
                e.Row.Description = ""
                e.Row.Description = "Zone : " & e.Row.Value.ToString() & ", Total of zonas : " & e.Row.Rows.Count & "    Total of meters: " & suma.ToString
            End If
            If e.Row.Column.Key = "Subzone" Then
                e.Row.Appearance.BackColor = Color.Tomato
                e.Row.Description = ""
                e.Row.Description = "Subzone : " & e.Row.Value.ToString() & ", Total of Subzones : " & e.Row.Rows.Count & "    Total of meters: " & suma.ToString
            End If

        End Sub