Hi!
I'm using the UltraGrid (in namespace Infragistics.Win.UltraWinGrid) and I want to sum all the values (integers) in a certain column in the grid and put the result in a textbox (not in an extra row in the grid!). How do I do that?
I'm using version 6.2.
Regards, Emelia
Hi,
I had the same issue last week and SummaryRows weren't the solution as they have to be visible in order for them to recalculate. I'd suggest using the UltraCalcManager and supplying a named reference and a formula to it. This should give you the column sum you need.
Regards, Mark
Which methodes/properties shall I use to supply the UltraCalcManager with a named reference and a formula?
What if I only want to sum certain rows in the column?
Say I have 10 rows in the column but only want to sum 5 of them and display it in a textbox? They do have a u_id, so how do I say "only sum these u_ids together"?
What you would do is create an unbound column in the grid and give it a formula using the "IF" function so that you give the unbound cell a value or 0 based on the u_id. Then you sum the unbound column.
Mike,
I hear what you are saying about adding the calculated field and summing it, but this is surely a long winded way...I basically have the same issue as tammy in that i am trying to carry out a conditional sum based on a simple expression. For instance on my text box the following will work
SUM([//gdBillCallsGrid/ConnectionBillCalls/CallCost])
but I cannot get the following to work
SUM(if([//gdBillCallsGrid/ConnectionBillCalls/CallCost] >10,[//gdBillCallsGrid/ConnectionBillCalls/CallCost],0))
I get "Incorrect type of argument or operand"
As I stated above, there is no way to do this with a single formula. You must use 2 formulas.
References in any formula are relative to the object to which the formula is being applied.If you are applying a formula to a grid column, then referencing another column really references the cell in the column in the same row as the cell whose formula is being calculated.
For example, if I have two columns in the grid called "Column 0" and "Column 1", then when I apply a formula to "Column 1" that references "[Column 0]", each cell in column 1 has a context (the row) by which it can get a corresponding cell in Column 0.
For a textbox, there is no such context. So if a TextBox refers to "Column 0", the reference represents the entire column. Therefore, in a TextBox, doing something like "if ([Column 0] > 10, [Column 0], 0)" is meaningless. Asking if a column is greater than 0 is a meaningless condition, as Column 0 is not a value, it's a list of cells.
I have implemented a calculated column and it works fine but it has rasied another issue. Is there any way to get the calcmanager to run it calculations against hidden records (hidden=true;)
I figured it out. When you want hidden rows included in the calculation you need to set the Override.FormulaRowIndexSource to FormulaRowIndexSource.Lstindex on the actual ultrawingrid.