I use a numeric updown control to allow the users to adjust numeric values to effect a change in my ultragrid. In my ultragrid InitializeLayout event I have the following:
... var band = e.Layout.Bands[0]; band.Columns["CalcMarkup"].Formula = "if ([Markup] > 0, [FinalCost]*([Markup]/100), 0)"; band.Columns["RemainingCost"].Formula = "if([CalcMarkup] > 0, 0, [FinalCost] )"; band.Columns["ForcedMarkup"].Formula = "if([RemainingCost] = 0, 0, ([RemainingCost]/[sumRemCost()])*[force()])"; ... grdMain.DisplayLayout.Bands[0].Summaries.Add("force", "[ForcedAdj()]", SummaryPosition.UseSummaryPositionColumn, grdMain.DisplayLayout.Bands[0].Columns["ForcedMarkup"]); ... var value = 1 - (nudMarginPer.Value/100); _marginFormula = string.Format("( ( ([finCost()]/{0})-sum([FinalCost]) )-sum([CalcMarkup])-5000000 )", "{0}"); band.Summaries.Add("ForcedAdj", string.Format(_marginFormula, value)); band.Summaries["ForcedAdj"].SummaryDisplayArea = SummaryDisplayAreas.None; ... grdMain.DisplayLayout.Bands[0].Summaries.Add("force", "[ForcedAdj()]", SummaryPosition.UseSummaryPositionColumn, grdMain.DisplayLayout.Bands[0].Columns["ForcedMarkup"]);in the numeric updown event: void nudMarginPer_ValueChanged(object sender, EventArgs e) { var value = 1 - (nudMarginPer.Value/100); grdMain.DisplayLayout.Bands[0].Summaries["ForcedAdj"].Formula = string.Format(_marginFormula, value); }
This works well in that when the user presses the updown buttons the summary (ForceAdj) values change and is reflected in the grid summary row. However the column formula for ForcedMarkup doesnt change until a second button press. So now the summary is correct however the value in the cell is off.
My question is this... How do I force the formula for ForcedMarkup (or any column formula) to refresh to reflect the current calcs?
I have tried forcing a grid update, calcmanager recalc, etc... nothing seems to work. I have attached a zip file containing the form.
thanks
Thank you for the simple program... it helped a lot... I have modified the program you sent me just slightly.... I added group by and you can now see the problem I am facing. Also we are using version 13.1.
Steps:
This is the problem I am having. The problem appears when I added a group by. Something I had not realized. Another thing too is that in our case, we have to set the default value of the updown control to 30. If you do this you will see the value is incorrect on the initial form load. only incrementing and then decrementing by 1 does the value seem to be correct.
Now add the following line in the InitializeLayout event at the bottom:
ultraGrid1.DisplayLayout.Rows.ExpandAll(true);
This will make things even more fun....
So... i guess this now begs the question ... how to fix this issue?
NOTE: I also tried this with 14.1 and the same issue/behaviour exists.
Hello Jeff,
Thank you for the provided code, based on it I’ve tried to reproduce the issue you’ve got by implementing a simple sample using formulas from your project. I’ve used Infragistics 14.1 for my test. Please see attached zip. When the updown button is pressed both the summary value and the cell value are changed in my sample. So could you please review my sampel and modify it in order to reproduce this issue, ones I have sample that demonstrates your issue I will be glad to investigate and researcher this further for you.
I am waiting for your feedback.
Hi,
There appears to be something wrong with the zip file you attached here. I can't unzip it, it just freezes up at 46%. Also, a form doesn't really do much good without a project and solution. Can you attach a completely sample project we can run to try this out?
There's nothing you have to do to get the formula to calculate. It should happen automatically. But it is asynchronous, so it might just be taking some time.