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
Hi Venkatesh,
You could use a Formula summary instead of the built-in summary types.
Place an UltraCalcManager component on the form with the grid in order to use formulas.
Thanks Mike, for your quick response!
While using CalcManager i landed into another issue :( - On my screen i've dynamic columns (i mean "Price0", "Price1" etc) -- How do i specify column in formula?
e.Layout.Bands[0].Columns["ColName"].Formula = "10 * [Col2]";
andalso I want formula to calculate the sum of same column.
Are you sure your summary is using a Formula and not just a SummaryType.Sum?
I tested this out and it worked fine for me.
Hi Mike,
Sorry, I was trying with SummaryType.Sum. When I changed to below code summary grid total dispaly has blank.
Band0.Summaries.Add("Total" + cnt, SummaryType.Formula, Band0.Columns[COL + cnt], SummaryPosition.UseSummaryPositionColumn);Band0.Summaries["Total" + cnt].Formula = "sum(" + COL + cnt + ")";Band0.Summaries["Total" + cnt].SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
Hello vbalingula,
I am checking about the progress of this issue. Please let me know If you need any further assistance on this.
Hi Boris/Mike,
Apologies for delay in response....
I've attached the sample project as requested by Boris, please let me know if you need any additional details from me!
Thank you for all your support!
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.
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.
If possible - can you please send me the example with Formula Summary?