I have a ultrawingrid with two bands (0,1) and i want to sum the "amount" cell from band 1 into the "total" cell in band 0, Its posible to that with UltraCalcManager?
Thanks in advance,
Alejandro Castrejon
Hi Alejandro,
Yes, you just use the name of the child band to reference the child column.
So if I have have a grid with a Root band ("Band 0") and a Child Band ("Band 1") and Band 1 contains an integer column called "Column 1", I would do something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band0 = layout.Bands[0]; UltraGridColumn totalColumn; if (band0.Columns.Exists("Total")) totalColumn = band0.Columns["Total"]; else { totalColumn = band0.Columns.Add("Total"); totalColumn.DataType = typeof(int); totalColumn.Formula = "Sum([Band 1/Column 0])"; } }
Is it possible the Sum Cell from 2 diff Grid.
Yes. To refer to an individual cell in a grid, you use the band name and index the row, then specify the column.
So, for example, to sum the first cell in two different grids, the formula would look something like this:
[//ultraGrid1/Band 0(0)/Column 0] + [//ultraGrid2/Band 0(0)/Column 0]
Hi
I have a ultrawingrid with two bands parent(band0) and child(band1) and i want to sum the child band payment column summary, to parent band payment column.
i am having data relation between parent and child
eg:
in, parent band- first row have
Party1, Payment columns
Child band - first row for Party1
Invoice1, Payment1 columns
Child band - second row for Party1
Invoice2, Payment2 columns.
need to sum child band payment1+payment2 values and added to payment column in parent band for Party1.
similarly for Party2..
Could you help me on this process?
Hi,
Where exactly do you want the sum to go? In a cell of the parent row? If so, then this is pretty easy to do.
All you have to do is handle the InitializeRow event and populate the value of a cell in the row with the sum of the two summaries from the child rows of that row.
So let's say I have two summaries on the child band and when I created those summaries, I assigned them each a key: "payment1" and "payment2". And let's assume that I have a column (either bound or unbound) in the parent band called Total, which will contain the sum of those two summaries. The code in the InitializeRow would look something like this.
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { // Is this a root band row? if (e.Row.Band.Index == 0) { int summaryValue1 = (int)e.Row.ChildBands[0].Rows.SummaryValues["payment1"].Value; int summaryValue2 = (int)e.Row.ChildBands[0].Rows.SummaryValues["payment2"].Value; e.Row.Cells["Total"].Value = summaryValue1 + summaryValue2; } }
The CalcManager calculations are performed continuously and asynchronously. You cannot prevent hte calculation from occurring based on the current row in the grid.
I suppose if you wanted to, you could set the CalcFrequency on the UltraCalcManager to Manual and then no calculations would be performed until you called the ReCalc method. But you cannot singly out a particular cell or formula, it's all or nothing.
sorry i did a mistake in child band summary.
now i got correct ,
one more thing needed , child band summary values updated to parent row only after move to next parent row,
i tried in summaryvaluechanged event but the previous parent rows value were cleared.
Grid.ActiveRow.ParentRow.Cells("Payment").Value = e.SummaryValue.Value
could you tell how to update parent row payment column when child row payment column value changed?
i took the initializerow event post for my form.
i just assign datasource at runtime
Dim summaryValue1 As Integer = CInt(e.Row.ChildBands(0).Rows.SummaryValues("Payment").Value)
an key not found exception occurs.
how to handle this?
Oops. I just realized you are using CalcManager, so you want to do this with Formulas.So please ignore my first post.
So in that case, you want to assign a formula to a column in the parent band (let's call it Total again) which is the sum of the two summaries in the child band. To refer to a summary in a child band you use the band name, followed by the summary key. To distinguish a summary from a column you have to use an empty set of parens after the summary key. So the code would look something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band0 = layout.Bands["Band 0"]; UltraGridBand band1 = layout.Bands["Band 1"]; UltraGridColumn payment1 = band1.Columns["Payment1"]; UltraGridColumn payment2 = band1.Columns["Payment2"]; band1.Summaries.Add("Payment1 Summary", "SUM ( [Payment1] )", SummaryPosition.UseSummaryPositionColumn, payment1 ); band1.Summaries.Add("Payment2 Summary", "SUM ( [Payment2] )", SummaryPosition.UseSummaryPositionColumn, payment2 ); UltraGridColumn total = band0.Columns["Total"]; total.Formula = @"[Band 1/Payment1 Summary()] + [Band 1/Payment2 Summary()]"; }