Hi,
I have a ultragrid that has a summary row. I also implemented hide/unhide row functionality as part of requirement. Now here the issue - when i hide the rows on gird it also affecting the summary row at the bottom i.e. .Sum is ignoring the values of hidden row its only calculating what’s visible on grid.
I also tried implementing ICustomSummaryCalculator but there also i'm not getting reference of hidden row!
Is there any setting/property to through i can tell summary field to consider hidden rows for sum?
Thanks
Venkatesh
I had the same problem and found a way to do it using a custom summary type. Essentially when you implement the ICustomSummaryCalculator, add a constructor to the class and pass in the grid by reference. Don't do anything in the AggregateCustomSummary method because it only sees the visible rows. Instead do a loop through of the passed-in grid in the EndCustomSummary method. This makes your grid available to your custom class and you can do anything with it inside the custom calculator.
Public Class MyCustomSummary Implements InfraWinGrid.ICustomSummaryCalculator
Private m_pGrid As InfraWinGrid.UltraGrid
Public Sub New(ByRef pGrid As InfraWinGrid.UltraGrid) m_pGrid = pGrid End Sub
Public Sub BeginCustomSummary(ByVal summarySettings As InfraWinGrid.SummarySettings, ByVal rows As InfraWinGrid.RowsCollection) Implements InfraWinGrid.ICustomSummaryCalculator.BeginCustomSummary End Sub
Private Sub AggregateCustomSummary(ByVal summarySettings As InfraWinGrid.SummarySettings, ByVal row As InfraWinGrid.UltraGridRow) Implements InfraWinGrid.ICustomSummaryCalculator.AggregateCustomSummary 'Do nothing End Sub
Private Function EndCustomSummary(ByVal summarySettings As InfraWinGrid.SummarySettings, ByVal rows As InfraWinGrid.RowsCollection) As Object Implements InfraWinGrid.ICustomSummaryCalculator.EndCustomSummary Dim intPos As Sys.Int32 = summarySettings.SourceColumn.Index Dim decSum As Decimal
If intPos >= m_decONUninvested.Length Then intPos = m_decONUninvested.Length - 1
For Each pRow As InfraWinGrid.UltraGridRow In m_pGrid.Rows If pRow.Cells(intPos).Value IsNot Sys.DBNull.Value Then decSum += FedCmsCommUtil.ToDecimal(pRow.Cells(intPos).Value) End If Next pRow
Return decSum End FunctionEnd Class
Hello Venkatesh,
Did you try this in your sample? I will be waiting for your feedback.
All you have to do is this:
//Summary using custom formula //SummarySettings s1 = Band0.Summaries.Add("PageTotal", SummaryType.Custom, new PageTotalSummary(), Band0.Columns["Col3"], SummaryPosition.UseSummaryPositionColumn, Band0.Columns["Col3"]); SummarySettings s1 = Band0.Summaries.Add("PageTotal", "sum([Col3])", SummaryPosition.UseSummaryPositionColumn, Band0.Columns["Col3"]);
Now...this doesn't work in your sample, because you are not setting the FormulaRowIndexSource. You have code to set it, but that code is never getting hit because the method is never being called. The ultraGrid1_InitializeLayout method isn't hooked up to the grid so it never gets hit. Once you actually hook up this method to the grid and the FormulaRowIndexSource is set, it work the way you want.
Hi Mike,
If possible - can you please send me the example with Formula Summary?
Hi Venkatesh,
I'm confused. Why is your sample using an ICustomSummaryCalculator. I beleive I already explained that this will not work. The only way to do this is to use a Formula summary.
If you are using NetAdvantage 12.1, there is another option, which is to use an external summary. The external summary is a new type which was added in 12.1 and it allows you to simply set the value of the summary in response to an event, so you could loop through the rows yourself.
But there is no other option in 11.2.