I'm really, really frustrated that I cannot find ANY information from Infragistics how to sum a row of data in a datagrid... NOT A COLUMN, A ROW! I know how to do column summaries...
I have an unbound grid that I don't know how many columns the row will have until run time.. How do I sum the values of the row and place them in the last column titled 'Total". Do I use Row_Initialize, UltraCalcManager (which I've never used..)... any help ??
This cannot be this difficult to accomplish!
Thanks.
You can easily do it with RowInitialize. In the event handler:
e.Row.Cells["Total"].Value = e.Row.GetCellValue(column1) + e.Row.GetCellValue(column2) ......
If setting the total value causing RowInitialize to fire again, you can disable the event temporarily before setting the value by using grid.EventManager.SetEnabled method.
Maybe there is a built-in solution for that that I'm not aware of.
There is indeed another approach that one can use, which makes use of the WinCalcManager component in conjunction with the WinGrid control. For an example, see the following article from our online help documentation of NetAdvantage for Win Client 2009 Volume 1:Creating a Calculated Column in WinGrid
Thanks for your suggestion, but I must be missing the boat here..
First, I played with that example all morning and it ended up being a total waste of time. First, I do not know how many columns of data is being returned for each instance of the grid. So the example, which shows me defined columns in the calculation, is of no help to me. I could have 2 columns for one run and 12 columns in the row the next run..
Second, perhaps we are on different definations of the word "ROW".. I need totals for each line, I can get the column totals, no problem.. I need the totals for the row going West to East, not the columns running north to south...
I don't understand why Infrag cannot give decent examples how their controls work.. This exercise has been a total waste of time... and causing a very upset client who can't understand why something as simple as getting a row total is so confusing...