Hi,
We use an UltraGrid in which we group rows and take the sum of values in columns. This sum is shown in the header. See the screenshot below. The red circles are wrong, the green circles are ok.
However, for columns of which ALL values within the group are Null (or Nothing), the Sum evaluates to 0,00 instead of Nothing. I looked at how this work for SQL queries. Here, a sum of all Null values evaluates to Nothing: SELECTSUM(Null) = Nothing (instead of 0,00)..
Does anyone have any idea whether this is possible, so that in the header we get Nothing instead of 0,00?
See below for a relevant piece of our code
Best regards, Henk Wagterveld
With e.Layout.Bands(0) With .Columns("Turnover".ToLower) .Style = ColumnStyle.Currency .Format = FormatUIlib.DefaultCurrencyFormat .CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .Header.Caption = "Grondslag" '= Dutch translation of Turnover .Header.Appearance.TextHAlign = Infragistics.Win.HAlign.Right .Width = 77 .Header.VisiblePosition = 4 .Hidden = False End With With .Columns("VatAmount".ToLower) .Header.VisiblePosition = 5 .Style = ColumnStyle.Currency .Format = FormatUIlib.DefaultCurrencyFormat .CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .Header.Caption = "Btw-bedrag" '=Dutch translation of Vat-amount .Header.Appearance.TextHAlign = Infragistics.Win.HAlign.Right .Width = 87 .Hidden = False End With End If End With
'Sum for op turnover and value added tax. With e.Layout.Bands(0) .Summaries.Clear() .Summaries.Add("Turnover", SummaryType.Sum, .Columns("Turnover"), SummaryPosition.UseSummaryPositionColumn).DisplayFormat = "{0:0.00}" .Summaries.Add("VatAmount", SummaryType.Sum, .Columns("VatAmount"), SummaryPosition.UseSummaryPositionColumn).DisplayFormat = "{0:0.00}" End With
With e.Layout 'Group by funcionality .Grid.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy 'Hide GroupBy UI .Grid.DisplayLayout.GroupByBox.Hidden = True 'Group With .Grid.DisplayLayout.Bands(0) If .SortedColumns.Exists("GroupByMembers") = False Then .SortedColumns.Add("GroupByMembers", False, True) .SortedColumns(0).AllowGroupBy = Infragistics.Win.DefaultableBoolean.True End If End With End With
I'm pretty sure that all of the built-in summary types (such SummaryType.Sum) are going to interpret a null in a numeric field as a 0. And I suspect the same is true if you use a Formula.
So if you want finer control over this, I think you will have to create your own ICustomSummaryCalculator This gives you the ability to handle the calculation yourself and you can deal with nulls however you like.
Hi Mike,
Should we log a feature request for this or is this a bug?
In our case we have 24 different columns and it might be quite a lot of work to handle this.
Or do you have another opinion?
Regards, Henk
Yes, that makes sense. Indeed, we don't have to build 24 calculators. I'll log a feature request as well. Thanks for your help.
This is not a bug, the grid intentionally interprets nulls as 0 for the purposes of formula and summary calculations.
You can certainly log a feature request for this: Submit a feature request to Infragistics
Are you saying that you have 24 completely different types of summary calculations to perform? If you are just doing the same thing, such as a Sum, on each column, then you only have to write one ICustomSummaryCalculator and use it for each column. You don't have to write the same code 24 times.