So Ive been breezing the Forums trying several ways to add a Summery of my child bands into their parent band. Ive really had little to no luck. Im still new to infragistics So I will ask you guys:
I have parent band Foo
Child band: Bar
I need the Price in child band bar To be summed for the multiple child bands and the total placed into the Subtotal column in Foo.
I'm working with a dynamically built grid that is receiving an object and need to handle this in the initialize grid or initialize row routine. Should I provide a formula and pass it to the column using the summarize.add? or can I add the formula directly to the cell?
PS Im a vb .net guy, Try to avoid the C# code.
Thanks in advance!
Hi,
Just to be sure I understand... you want to have a cell in band Foo which contains the calculated sum or a column in band Bar for all of the child rows of that row. Is that right?
The easiest way to do this would be to add a summary to the child band. This will sum up the child rows under parent (Foo) row. Then you could simply handle the InitializeRow event and populate the cell in each row in band Foo with the value from the summary of it's child rows.
That is what I want, but the grid is interactive and the total will change and the whole grid is being built dynamically. I found a not so elegant way to do it with the collectionChange event of the object but it is by far not a pretty thing to look at from a code perspective.
is there a summary.ADD( childbandIwantTosummerize , ParentBandTargetCell) type of option for it?
I'm not sure I understand the problem.
If you add a summary to the child band using band.Summaries.Add, then the grid will calculate the summary dynamically. It will be updated any time anything changes. So you don't have to do anything else.
Copying that summary value into the cell in the parent row is a little bit trickier. You can use the InitializeRow event for this. This event will fire when the parent row is created and any time a value in the parent row changes. So that leaves a little bit of a hole, because the parent row cell won't update by itself when the child rows change. So you can handle that case by handling the grid's SummaryValueChanged event.
Another option, which might be a bit easier, would be to use a Formula on the parent column which references the summary. With a Formula, you could skip the InitializeRow and the SummaryValueChanged code, because the grid would recognize changes in the child summary and automatically update the parent cell.
I whipped up a quick sample project using formulas.
Thanks Mike! Worked like a charm!