Is it possible to have multiple summary rows in a single band. I have data like below and need to show Summaries as Subtotal for each unique ColA value. Is it possible to show as below without manupulating data in underlying datasource.
Thank you
ColA ColB Col C
1 a 2 1 b 51 c 3
SubTotal 10
2 x 12 z 2
SubTotal 3
3 i 43 j 103 k 43 i 5 Subtotal 23
What you can do is apply a summary to Col C, then use the OutlookGroupBy feature of the grid and group by Col A.
Set grid.DisplayLayout.ViewStyleBand to OutlookGroupBy. Then use the SortedColumns.Add method on the Band to sort column A and specifiy true for groupBy.
Thanks for quick reply. I did the samething. But that visually changes a lot. I need this first row to appear as normal first column or atmost column with merged cellstyle but definitely not as a separate band. I tried setting GroupByColumnsHidden = DefaultableBoolean.False but could not figure out how to get rid of GroupByRows. Also this ColA is not necessarily the first column, it could be any column in the table.
please advice.Thank youbhavani
Hi Kelly,
Sorry, this turns out to be a lot more complicated than I thought it would be.
I'm attaching a small sample project here to demonstrate.
It looks like summaries in the grid don't use their keys as the reference names. I'm not sure why this is, but it's probably so that column keys and summary keys are always unique.
It also appears that there is a bug when you try to use a summary reference in a formula in another grid. It raises a NullReferenceException and I don't know why. Feel free to Submit an incident to Infragistics Developer Support regarding this bug and include my sample project if you like.
So it looks like the only way this will work right now is if you will re-include the original formula in the second formula. This is not very efficient, but it's the only way I cound find to get it to work.
Hi Mike,
Thank you so much for your research into this matter and for taking the time to create a sample application.
When following along with the sample projects from the support website, I was able to reference the summary in another grid; however, it references it as follows (I would attach a sample, but it is larger than 200kb): [//UltraGrid1/Order Details/Grid1Sum()]
[//UltraGrid1/Order Details/Grid1Sum()]
Whereas the summary in the current grid is simply referenced as: [Grid2Sum()]
[Grid2Sum()]
In the example, data is bound via the gui, whereas for my project it will be bound programmatically; therefore, my Band(0) does not have a key to reference. Is that why I am unable to reference my band that contains the summary correctly?
Thanks again!~Kelly
Update:
My sample was working, but I just tried running it again and I do get the null reference exception as you mentioned. I suppose I will submit an incident report, but in the meantime attempt to do it via your other suggestion - ICustomSummaryCalculator - if you could point me in the right direction with that I would be most appreciative.
Okay. Here's a quick sample of using an ICustomSummaryCalculator to do the same thing.
Sorry to be such a bother, but i was wondering if you could point me in the right direction in converting part of your class from c to vb.
This is what I have so far, but I was not sure how to convert this part:
Imports Infragistics.Win.UltraWinGridImports Infragistics.Win.CalcEngineImports Infragistics.Win.UltraWinCalcManagerPublic Class MySummaryCalculator Implements ICustomSummaryCalculator Private FirstGrid As UltraGrid
' this is what you had: public MySummaryCalculator(UltraGrid otherGrid) { this.otherGrid = otherGrid; } ' this is what I have ??? - or is it a property?:
' this is what you had:
public MySummaryCalculator(UltraGrid otherGrid)
{
this.otherGrid = otherGrid;
}
Public Sub MySummaryCalculator(ByRef FirstGridName As UltraGrid) Me.FirstGrid = FirstGridName End Sub
Public Function EndCustomSummary(ByVal summarySettings As SummarySettings, ByVal rows As RowsCollection) As Object Implements ICustomSummaryCalculator.EndCustomSummary Dim mySummaryValue As Decimal = CType(rows.SummaryValues(0).Value, Decimal) Dim otherGridSummary As Decimal = CType(Me.FirstGrid.Rows.SummaryValues(0).Value, Decimal) Return mySummaryValue + otherGridSummary End Function
Public Sub BeginCustomSummary(ByVal summarySettings As SummarySettings, ByVal rows As RowsCollection) Implements ICustomSummaryCalculator.BeginCustomSummary ' do not need End Sub Public Sub AggregateCustomSummary(ByVal summarySettings As SummarySettings, ByVal row As UltraGridRow) Implements ICustomSummaryCalculator.AggregateCustomSummary ' do not need End SubEnd Class
Public Sub BeginCustomSummary(ByVal summarySettings As SummarySettings, ByVal rows As RowsCollection) Implements ICustomSummaryCalculator.BeginCustomSummary ' do not need End Sub Public Sub AggregateCustomSummary(ByVal summarySettings As SummarySettings, ByVal row As UltraGridRow) Implements ICustomSummaryCalculator.AggregateCustomSummary ' do not need End Sub
End Class
That's the constructor of the class. So in VB, you would do:
Public Sub New(ByRef FirstGridName As UltraGrid) Me.FirstGrid = FirstGridName End Sub
Mike,
I think same code what I have for the custom summary works just fine with a new grid. For some reson the old grid is having troubles with it.
For now , I am good.
Thanks a lot , Venkat.
Thank you very much for taking time to look into this.
You are right in saying summary formula line is commented but in the actual code its not.
If I follow you correct , scrolling down to the bottm should calulate the summaries but I dont see the correct summaries. SO I was running the same code in debugger , then I see that the custom class New method getting called but dont any other methods getting called and eventually summaries are not currect.
I am not sure why those beginSummary and other methods are not gettting called when step though debugger. Any clue ?
In the other post that I had posted the complete code.
I really appreciate your help on this as I am in crunch state of the project.
Thanks, Venkat.
Hi Venkat,
Well, the line of code you have here which adds the summary is commented out. :)
Assuming that's just a typo here in this forum post and that this line is not commented out in your actual code, then my next guess would be that the summary is not yet visible on the screen. The summaries don't get calculated until they are needed. So if your summary is at the bottom of the rows collection (which is the default), the calculation will not occur until you scroll down to the bottom of the rows and bring the summary into view.
Hi all ,
I followed this thread and wrote my customSummary class and used the Custom summaryType.Tried using the same but my methods inside the custom class didn't get fired. Ami doing anything wrong.
InterCompGrid3.DisplayLayout.Bands(0).Columns("CGDTH").AllowRowSummaries = AllowRowSummaries.True 'InterCompGrid3.DisplayLayout.Bands(0).Summaries.Add("summaryCGDTH", SummaryType.Custom, New InterCompCustomSummary("CGDTH"), InterCompGrid3.DisplayLayout.Bands(0).Columns("CGDTH"), SummaryPosition.UseSummaryPositionColumn, Nothing)
Can anybody give a qucik pointer.
Thanks a Lot, Venkat.
I'm not sure off the top of my head, but if there is a way, it would probably be via the SummaryDisplayAreas property on the Override.