Is it possible to have multiple summary rows in a single band. I have data like below and need to show Summaries as Subtotal for each unique ColA value. Is it possible to show as below without manupulating data in underlying datasource.
Thank you
ColA ColB Col C
1 a 2 1 b 51 c 3
SubTotal 10
2 x 12 z 2
SubTotal 3
3 i 43 j 103 k 43 i 5 Subtotal 23
What you can do is apply a summary to Col C, then use the OutlookGroupBy feature of the grid and group by Col A.
Set grid.DisplayLayout.ViewStyleBand to OutlookGroupBy. Then use the SortedColumns.Add method on the Band to sort column A and specifiy true for groupBy.
Thanks for quick reply. I did the samething. But that visually changes a lot. I need this first row to appear as normal first column or atmost column with merged cellstyle but definitely not as a separate band. I tried setting GroupByColumnsHidden = DefaultableBoolean.False but could not figure out how to get rid of GroupByRows. Also this ColA is not necessarily the first column, it could be any column in the table.
please advice.Thank youbhavani
Hi,
vpratti said:Right now if I set AllowGroupBy on user name, it is fine for the first user, for the second user it will be the sum of first user and second and for third user it will the sum of first, second and third.
It sounds to me like this is a problem with your implementation of ICustomSummaryCalculator. You are probably storing your summary in a member variable on the class. You are probably not clearing out the member variable when a new calculation begins.Make sure you are handing the BeginCustomSummary method and resetting any variables that are used in the calculation of your summary.
I am now having a similar problem. I have two custom summary calculators, one for FTEs (people) and one for Dollars.
When the grid does not have a column in the group by, the custom summaries work as they should:
However, when a column is added to the group by, it seems as though the two custom summaries are never updated, whereas the regular summary does update:
Also, another question related to this - is it posible to have the summary rows display for not only the rows in the group bys but also at the bottom as a summary of all of the rows?
Any help would be greatly appreciated!
Thanks,~Kelly
Can You try adding the below line at the end,
UltraGrid1.DisplayLayout.Override.AllowRowSummaries = AllowRowSummaries.Default
Hi vprattiIt still behaves the same way, but thanks for the suggestion!~Kelly
Below is the code I am using and it would calculate the row summaries just fine,
ugDashData.DataSource = dsdata.Tables(0)
ugDashData.DisplayLayout.Bands(0).Columns("USER").AllowGroupBy = DefaultableBoolean.True
ugDashData.DisplayLayout.Bands(0).SortedColumns.Add("USER", False, True)
ugDashData.DisplayLayout.Override.AllowRowSummaries = AllowRowSummaries.True
Dim BatchSummary As SummarySettings = ugDashData.DisplayLayout.Bands(0).Summaries.Add("COLUMN1", SummaryType.Count, ugDashData.DisplayLayout.Bands(0).Columns("COLUMN1"), SummaryPosition.UseSummaryPositionColumn)
Dim ImageCountSummary As SummarySettings = ugDashData.DisplayLayout.Bands(0).Summaries.Add("COLUMN2", SummaryType.Sum, ugDashData.DisplayLayout.Bands(0).Columns("COLUMN2"), SummaryPosition.UseSummaryPositionColumn)
Dim DocCountSummary As SummarySettings = ugDashData.DisplayLayout.Bands(0).Summaries.Add("COLUMN3", SummaryType.Sum, ugDashData.DisplayLayout.Bands(0).Columns("COLUMN3"), SummaryPosition.UseSummaryPositionColumn)
Dim TotalTimeSummary As SummarySettings = ugDashData.DisplayLayout.Bands(0).Summaries.Add("COLUMN4", SummaryType.Custom, New clsTotalTimeByUser(), ugDashData.DisplayLayout.Bands(0).Columns("COLUMN4"), SummaryPosition.UseSummaryPositionColumn, Nothing)
Dim ImageRateSummary As SummarySettings = ugDashData.DisplayLayout.Bands(0).Summaries.Add("COLUMN5 ", SummaryType.Custom, New clsImageRateCalculator(), ugDashData.DisplayLayout.Bands(0).Columns("COLUMN5"), SummaryPosition.Right, Nothing)
BatchSummary.DisplayFormat = "COUNT = {0}"
ImageCountSummary.DisplayFormat = "TOTAL = {0}"
DocCountSummary.DisplayFormat = "TOTAL = {0}"
TotalTimeSummary.DisplayFormat = "= {0}"
ImageRateSummary.DisplayFormat = "PER HOUR = {0}"
You may ignore the column4 and 5 I used here as I was using custom summary type to calculate the percentage and rate.
Let me know if this works for you.
Hi vpratti,
The problem I am having is not with the normal summaries like the example you provided, since they are calculating correctly (first row in my summary area), but with my custom summaries (second and third row of summaries)
I also used custom summaries in the code I sent you and this is the custom summary class I am using. I was advised to write a seperate class for each custom summary calculation I do. So the Begin summary and End summary are to present for each summary calculation.
You can try this.
Public Class clsImageRateCalculator
Implements ICustomSummaryCalculator
Private TotalTimeinSec As Integer = 0
Private TotalImages As Integer = 0
Private ImageRate As String = 0
Private Sub BeginCustomSummary(ByVal summarySettings As SummarySettings, ByVal rows As RowsCollection) Implements ICustomSummaryCalculator.BeginCustomSummary
' Begins the summary for the SummarySettings object passed in. Implementation of
' this method should reset any state variables used for calculating the summary.
Me.TotalImages = 0
Me.TotalTimeinSec = 0
Me.ImageRate = 0
End Sub
Private Sub AggregateCustomSummary(ByVal summarySettings As SummarySettings, ByVal row As UltraGridRow) Implements ICustomSummaryCalculator.AggregateCustomSummary
Try
Dim ElapsedTime As Object = row.GetCellValue(summarySettings.SourceColumn.Band.Columns("ELAPSED TIME"))
Dim ImageCount As Object = row.GetCellValue(summarySettings.SourceColumn.Band.Columns("# IMAGES"))
' Handle null values
If ElapsedTime Is DBNull.Value Then
Return
End If
' Convert to decimal.
Me.TotalTimeinSec += Convert.ToInt32(ElapsedTime)
Me.TotalImages += Convert.ToInt32(ImageCount)
Catch e As Exception
' This should not happen if the columns are numeric.
Debug.Assert(False, "Exception thrown while trying to convert cell's value to decimal !")
End Try
Catch ex As Exception
Throw (ex)
' Here is where we process each row that gets passed in.
Private Function EndCustomSummary(ByVal summarySettings As SummarySettings, ByVal rows As RowsCollection) Implements ICustomSummaryCalculator.EndCustomSummary
' This gets called when the every row has been processed so here is where we
' would return the calculated summary value.
If TotalImages > 0 Then
Me.ImageRate = Math.Round(Convert.ToDouble((TotalImages / TotalTimeinSec) * 3600), 1).ToString()
Me.ImageRate = Me.ImageRate + " (images/hr)"
Return Me.ImageRate
End Function
End Class
Thanks vpratti,
I also have separate classes for the summaries, however, I was not using BeginCustomSummary.
I will look at your code and try it out. One of mine is as follows:
Public Class TotalFtesCalculator Implements ICustomSummaryCalculator Private GridToUse As UltraGrid Private SummaryName As String Private HoursInMonth As Decimal Public Sub New(ByRef Grid_To_Use As UltraGrid, ByVal Summary_Name As String, ByVal Hours_In_Month As Decimal) Me.GridToUse = Grid_To_Use Me.SummaryName = Summary_Name Me.HoursInMonth = Hours_In_Month End Sub Public Sub BeginCustomSummary(ByVal summarySettings As SummarySettings, ByVal rows As RowsCollection) Implements ICustomSummaryCalculator.BeginCustomSummary ' do not need ??? End Sub Public Sub AggregateCustomSummary(ByVal summarySettings As SummarySettings, ByVal row As UltraGridRow) Implements ICustomSummaryCalculator.AggregateCustomSummary ' do not need ??? End Sub Public Function EndCustomSummary(ByVal summarySettings As SummarySettings, ByVal rows As RowsCollection) As Object Implements ICustomSummaryCalculator.EndCustomSummary Dim SummaryValue As Decimal = CType(Me.GridToUse.Rows.SummaryValues(Me.SummaryName).Value, Decimal) Dim SumValue As Decimal = SummaryValue / HoursInMonth Return SumValue End Function End Class
Thanks,
Kelly
I updated my custom summary as follows and now it works --> I realized I had too many private variables that I didn't need!
Imports Infragistics.Win.UltraWinGridPublic Class TotalFtesCalculator Implements ICustomSummaryCalculator Private SummaryName As Strings Public Sub New(ByVal Summary_Name As String) Me.SummaryName = Summary_Name End Sub Public Function EndCustomSummary(ByVal summarySettings _ As SummarySettings, ByVal rows As RowsCollection) _ As Object _ Implements ICustomSummaryCalculator.EndCustomSummary Dim SummaryValue As Decimal = _ CType(rows.SummaryValues(Me.SummaryName).Value, _ Decimal) Dim FteValue As Decimal = _ SummaryValue / CType(rows(0).GetCellValue _ ("HoursInMonth"), Integer) Return FteValue End FunctionEnd Class
Imports Infragistics.Win.UltraWinGridPublic Class TotalFtesCalculator Implements ICustomSummaryCalculator Private SummaryName As Strings Public Sub New(ByVal Summary_Name As String) Me.SummaryName = Summary_Name End Sub Public Function EndCustomSummary(ByVal summarySettings _ As SummarySettings, ByVal rows As RowsCollection) _ As Object _
Implements ICustomSummaryCalculator.EndCustomSummary Dim SummaryValue As Decimal = _ CType(rows.SummaryValues(Me.SummaryName).Value, _ Decimal) Dim FteValue As Decimal = _ SummaryValue / CType(rows(0).GetCellValue _ ("HoursInMonth"), Integer) Return FteValue End FunctionEnd Class
Thanks again,Kelly
Now that the custom summary issue has been resolved, does anyone know if there is a way to have a total of each of the groups, i.e. a total of totals, at the bottom of the topmost group?
Here is an example - for the two groups of the column 'Proj' there are summaries. I would like to know if there is a way to have a summary of the totals in the next level group, 'Eff Mgr':