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.
To sum a column, you add a summary (of SummaryType.Formula) and the formula for that summary would look something like this:
"Sum([columnName])"
Hi Mike,
How do I get a reference of current column? As I said in my previous post i've dynamic columns in grid.
I'm not sure exactly what you mean by "current" column. There is no "current" column in the grid. There's an ActiveCell and an ActiveRow. So maybe you want the column associated with the ActiveCell? If so, then you would get it like this:
this.ultraGrid1.ActiveCell.Column
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?
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.
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!