I've scrapped some initial work I did using Fomulas in summaries and instead I'm trying to implement a customer summary using my own class that implements ICustomSummaryCalculator.
So far this is proving to be much easier and is producing the results I'm looking for. I do have one question however.
My data set will be grouped-by a particular column. The summary for the groups is giving me the result I want. But on the grand total line, I'd like to output a slightly different value.
It seems what I'm looking for is the ability to know in my summary class that implements ICustomSummaryCalculator if the summary it's currently calculating is for the grand total line. If I could do that I'd have the ability to say: if (isGrandTotal) return A, else return B.
Thanks!
Chris Rowland
Hi Chris,
The ICustomSummaryCalculator is called for each rows collection. I would think that for the grand total summaries when the grid is grouped, that the rows you get would be a collection of UltraGridGroupByRow objects, instead of the normal UltraGridRow. Is that not the case?
I’ve been in communication with Mike and it appears that the rows passed back to the iCustomSummaryCalculator are the ultraGridRow rows. It does not fire for the UltraGridGroupByRows.
I was wondering if you had been able to resolve your question regarding the grand totals.
I created a sample using the grand totals with multiple columns as sortedColumns and I have different values for the same summary value dependent upon which level of the groupby columns the calculation is related to.
If you could be of any assistance, please let me know.
Marianne
Hi Marianne,
I did ultimately solve the issue (for us anyway).
I removed all my code from the BeginCustomSummary and AggregateCustomSummary methods.
Then in the EndCustomSummary method I iterate on rows.GetAllNonGroupByRows to computer my summary value.
It appears that when EndCustomSummary is called while computing the summary for a group total, the GetAllNonGroupByRows are just the rows for that group. But when EndCustomSummary is called for the grand summary, GetAllNonGroupByRows returns all rows in the grid. For me, this allowed me to compute the grand total differently.
I'm not thrilled about the fact that this approach is inefficient (I wind up doing multiple iterations through the rows, first what the ultragrid does automatically, then what I do myself after the fact). But it was the best I could come up with.
Good luck!
Chris
Thanks Chris! Worked like a charm although I don't like how it is implemented either. But we don't have that many rows to process (about 400) so I guess it is not so bad after all.
Hi IsraelTan,
I see your recent post on this thread.
Please let me know if there is anything I can help you with.