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
440
Band grouping or sum of rows
posted

I have a grid with multiple bands.

One of the bands has more than 10 rows but I can sum them in order to just have 2 rows (because the 10 rows or more are just of 2 types TAX or OTHER:

Type Col      Desc Column         Amoun Column

TAX                SERVICE TAX            $80
TAX                SERVICE TAX            $91
TAX                SERVICE TAX            $102
.....
OTHER         OTHER ITEM             -$37
OTHER         OTHER ITEM              $85
.... 

 So I want to have just 2 rows but with the corresponding sum of the amount column.

How can I do that in a specific band of the grid? I just want to have:

TAX                SERVICE TAX            $sum of taxes
OTHER         OTHER ITEM             $sum of others

Hope someone can help me!!

Thanks,

Alejandro

Parents
  • 469350
    Offline posted

    Hi Alejandro,

    I think you could acheive what you want using the OutlookGroupBy feature of the grid. You would simply group the grid by the "Type Col" column and this would create a sort've artificial hierarchy with two rows at the root level and then each parent row would have the "real" data rows as it's child rows. 

    To do this in code, you would do something like this:


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                UltraGridLayout layout = e.Layout;

                // Enabled OutlookGroupBy
                layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;

                // Hide the GroupByBox so the user cannot change the groupings.
                layout.GroupByBox.Hidden = false;

                // Group by the Type Col column.
                layout.Bands[0].SortedColumns.Add("Type Col", false, true);
            }

     

     

Reply Children