Hi,
We have a grid with a column named GP. We would like to make this the Average of two sums of two other columns, cost and sell.
I thought it should be this (totalCost/totalSell or the key's for two other summaries on the same grid)
.Formula = (AVG[totalSell()] - AVG([totalCost()]) / AVG([totalSell()]
However it does not work. Even if try a simple formula like
.Formula = SUM([gp])
I get just an empty grey square.
I am sure we are missing something simple
EXAMPLE
e.Layout.Bands[0].Summaries.Add("gpavg", SummaryType.Formula, e.Layout.Bands[0].Columns["gp"]); e.Layout.Bands[0].Summaries["gpavg"].Formula = "SUM([gp])";
Thanks,
M
Hello,
To implement formulas on your Grid, please drag the UltraCalcManager component from the Toolbox onto your form. This will extend the capabilities of all the controls on the form. WinGrid needs this component on the form in order to support the formulas.
Let me know if you have any questions. Sincerely,Sahaja KokkalagaddaAssociate Software Developer
Hi. Thank you for your response.
We do have (and did) have a calc manager on the form. Can you verify how the formula might look for what I am describing?
M.
Hi Mel,
If you have a CalcManager on the form, then it should work. Especially with such a simple formula like in your second example. If the summary cell is blank, there are only two other reasons I can think of:
1) You are applying an Isl or appearances such that the summary ForeColor is transparent or the same as the BackColor - the text is there and you simply can't see it.
2) Something has gone wrong and the CalcManager is not properly hooked up to the grid. This typically happens in the Designer code for the form. You should see a line of code in the Designer.cs file something like this:
this.ultraGrid1.CalcManager = this.ultraCalcManager1.
If that's not happening, then you might have to just manually add that line of code in the Form's Constructor or in the Designer file.
Thanks Mike. I have tried/checked those things but with the same result. The summaries work fine for the built in types like Sum or Average. It seems only to happen when we use Formula. The GP summary is setup like:
e.Layout.Bands[0].Summaries.Add("gpavg", SummaryType.Formula, e.Layout.Bands[0].Columns["gp"]);
e.Layout.Bands[0].Summaries["gpavg"].Formula = "sum([gp])";
I have tested the code you posted here and it is working as expected. I was able to calculate the sum([gp]) by setting it as a formula for band summaries. I have tested this with 17.2.1000 version if you are using a different version of Infragistics then please let me know and I will modify my test environment to match yours.
I will further look into this issue as soon as I hear back from you.
Sincerely,Sahaja KokkalagaddaAssociate Software Developer
Hi Sahaja,
I am using that same version. Can you post the code or the test project so I can compare?
Hello M,
Please refer to the attached project on how to implement the required summary formula. The code related to this is in the Grid InitializeLayout event.
e.Layout.Bands[0].Summaries.Add("sumarryKey", SummaryType.Formula, e.Layout.Bands[0].Columns["A"]); e.Layout.Bands[0].Summaries["sumarryKey"].Formula = "Sum([A])";
Let me know if you have any questions.