How to force all summaries to recaculate in a WinGrid when a cell value changed?
There are a lot of factors at work here. If you are using CalcManager formulas then the summaries are not refreshed when they are off-screen. This is to optimize performance. So in such a case, you would have to force the calculations to complete, which is not a trivial operation and it would have to happen synchronously, which might cause your UI to lock up for a bit. You also can't control the order in which calculations are performed, so if there are other pending calculations, there's no telling which ones will get calculated first. To force the calculations, I think you would have to set CalcManager.CalcFrequency to manual, then call CalcManager.ReCalc. And then you would probably need to set CalcFrequency back to what it was. A simpler solution might be to simply ensure that your summaries are always visible, like using Fixed summaries at the top of bottom of the grid.
How we call SummarySetting Refresh in vb.net for this force recalculation. I am deleting an ultragrid row which is having scroll and its summary which I have taken in to variable is not getting updated till I mannually scroll down to summary portion.
Co-worker found a work around.
string formula = string.Empty; foreach (SummarySettings setting in ultraGrid1.DisplayLayout.Bands[0].Summaries) { setting.Refresh(); //forces recalc of SummaryType.Sum //Rest is for SummaryType.Formula formula = setting.Formula; setting.ResetFormula(); setting.Formula = formula; }
Enjoy.
I have submited a ticket with the Developer Support with a sample project. I will update this thread with the status of the ticket.
Thanks for your help Mike
************************************************
App: http://ko.infragistics.com/TestProjectUploads/GridSummaryTest57200816527283.zip - VS 2005 solution. Should be able to work if you just copy the Win dll to the debug folder.
Steps to reproduce:Unzip. Copy 8.1v of Infragistics2.Win into the exe folder (I had to take it out because of your size req)Run appClick First button This will change the values in the grid but not the summaries
Click Second Button This will force a Refresh() of all the summaries, as you can see only one is updated. The SummaryType.Sum one.Manually change a value in the grid This will make all summaries recalculate
Okay, there are a number of issues here.
First, when you "import" are you setting the values of the cells in the grid? Or are you setting the values in your data source? If it's in the Data Source, then what kind of data source are you using? If your data source is a BindingList, then it should be notifying the grid of the change and the grid shuold automatically update any non-formula summaries. If your data source is a List (as opposed to a BindingList) then it will not send notifications of updates and the grid will not know to refresh, so you will need to refresh the grid and the summaries manually. Maybe you are already doing something that is forcing a refresh on the grid cells.
The second issue is the Formula Summaries. If a value in a cell changes that influences a summary value, then the summary value should update automatically. But again, if you are changing a value through the data source and the data source is not notifying the grid of a change, then we're back to the same limitation as non-formula summaries.
If that's not the case, then it may depend on how you are checking that the summary value has not been updated. If you set a value in a grid cell, for example, and then immiediately try to read out the value of the summary in the next line of code, this will not work. This is correct, because Formulas are (by default) calculated asynchronously. You may be able to get around this by calling the Recalc method on the CalcManager. But theoretically, the SummarySettings.Refresh method should do this for you. If that's not working, then it's a bug and you should Submit an incident to Infragistics Developer Support. If you can include a small sample project demonstrating that it doesn't work, that would be a big help.