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

    Sorry Mike, I sending you this new image, I hope you understand me now

    Ok Mike, sorry for this again
    I´m trying to explain myself as well as I can

    We should forget all of the above and start again...

    ok, I have my ultragrid in groupbyrows (my table have 3 columns, Zone, Subzone and mts),
    like this:

     +zone
        +subzone
            mts  

    so, in the beginning, i didn't know how to change the description text for each groupbyrow,
    for that, I used InitializeGroupByRow and I changed for a custom text  the description of each groupbyrows
    using  e.Row.Description="My custom text"

    everything it's ok here (IMAGE 1 AND 2)

    But  I need the sum of the column "mts" and put it in the groupbyrows ((IMAGE 3)
    In this part is where i'm having problems, because in the groupbyrows the result Of The Sums
    is displayed with along the source column (mts): some like this: "mts sum=[resultOfTheSum]"
    To change sum=[resultOfTheSum] for a custom text (IMAGE 4) , I used:

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


    but, mts is still diplaying with along my custom text "Total of meters = {0}". (IMAGE 4)


    *******************************************************************************************************
    *******************************************************************************************************
    My code
    *******************************************************************************************************
    *******************************************************************************************************

    Imports Infragistics.Win

    Public Class SummaryGroupByRow

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

            ' Note. In this part, I will use data from a database,

            ' but there's so much information, for that reason   I use the code below to populate my ultragrid

            ' to simplify my real proyect



            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

           ' Without this code and InitializeLayout code (except AutoFitStyle),

           ' Ultragrid has an appearence as shown in the image 1
           ' Using the code below, Ultragrid has an appearence as shown in the image 2


            If e.Row.Column.Key = "zone" Then

    e.Row.Description = "Zone : " & e.Row.Value.ToString() & ", Total of Subzones : " & e.Row.Rows.Count
                e.Row.Appearance.BackColor = Color.Purple
                e.Row.Appearance.ForeColor = Color.Yellow
                e.Row.Appearance.FontData.Bold = DefaultableBoolean.True

            End If
            If e.Row.Column.Key = "Subzone" Then
     e.Row.Description = "Subzone : " & e.Row.Value.ToString() & ", Total of rows : " & e.Row.Rows.Count
                e.Row.Appearance.BackColor = Color.Tomato
                e.Row.Appearance.ForeColor = Color.Black
                e.Row.Appearance.FontData.Bold = DefaultableBoolean.True
            End If



        End Sub

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

           
           
            UltraGrid1.DisplayLayout.AutoFitStyle = AutoFitStyle.ExtendLastColumn


            ' Before to add this code and after have added InitializeGroupByRow code ,

            ' Ultragrid has an appearence as shown in the image 1-2
            ' After I add the code below, Ultragrid has an appearence as shown in the image 3
            ' Default summary caption is displayed
            ' for exmaple "mts sum=[theSum]" where mts is the source column summarized


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



            'If I use DisplayFormat , it changes "mts sum=[theSum]" to "mts Total of meter = [theSum]"
            'but I don't want "mts" in the summary caption (image 5) 
            'summary.DisplayFormat = "Total of meters = {0}"

            ' I dont Know for what reason "mts" is displayed

        End Sub

    End Class





    What can I do to remove "mts"?
    What could be happening?