Hi,
Firstly apologies if this is a simple mistake on my part or has been covered elsewhere but I've just started back with the grid and calc manager and am struggling to get the attached to work (VS2010 with 2013.2075)
Simple project attached and when I click in the new row the formula for column d doesn't appear to work but it works fine for existing rows. If I change the DeferredCalculationsEnabled to True on the calc manager then it works fine but my summary isn't fully calculated unless the grid is fully scrolled. I've tried various combinations of the DeferredCalculationsEnabled and CalcFrequency but just can't seem to get it to give a complete summary and complete the formula for a new row.
Any help greatly appreciated.
Thanks
Mike, I can confirm that we now have a working solution and once again thanks for your time on this.
Cheers
So we took another look, and it looks like fixing this in the control would be extremely dangerous and have a high potential for breakage.
The good news is that I found another workaround that I think should be acceptable and get you what you want. In fact, I am pretty sure this workaround will fix both of the issues you reported here, and alleviate the need for the changes in your custom summary calculator.
All you have to do is set the FormulaRowSourceIndex to either RowIndex or ListIndex.
By default, formulas are based on the VisualIndex of the rows. Usually, this doesn't matter, since you don't often use formulas that rely on the relative indices of rows. And such is the case with your sample - you aren't using any row indices in your formulas. The reason the AddRow isn't calculating is because it's Index is -1, and the CalcManager things it's an invalid row.
By switching the index to use RowIndex, both the summary and the cell in the AddNew row calculated immediately. You still need to set DeferredCalculationsEnabled to false, but as I mentioned above, that doesn't really matter since you have a summary that forces the calculation of every row, anyway.
So in your sample, I just added this line of code to the Form_Load
Me.UltraGrid1.DisplayLayout.Override.FormulaRowIndexSource = FormulaRowIndexSource.RowIndex
No worries Mike, I'll await the outcome of your investigation.
You are correct. I didn't notice that the sample project was working around the problem by setting DeferredCalculationsEnabled to true in BeforeEnterEditMode. So the issue with the TemplateAddRow still exists.
I will re-open the issue and we will look into this again and try to get it fixed. Once that issue is fixed, then you should be able to achieve what you want by setting DeferredCalculationsEnabled to false.
Once again, I apologize for the confusion.
Mike and Michael, many thanks for your help on this issue. I think we've all spent plenty of time on this already and it does appear, to me, that there isn't an easy solution to this. I thought originally I might just be missing something and a quick change of property values would sort it out. In summary and to clarify what I'm seeing with the last few posts:
1. Summary not working when deferred calcs is TRUE initially - having inserted the extra lines of code in the previous post then yes I agree that the summary now does work as expected without scrolling to the bottom of the grid. However, template row doesn't work.
2. I've checked the template issue in isolation again using 2014.1 and it still doesn't work with deferred calcs set to FALSE initially. I think it may appear to work in your sample as you set the value to TRUE in the BeforeEnterEditMode event.
After playing a little again the best value in my situation for deferred calcs is TRUE as it allows the template to work and the summary even updates when the template is getting updated. The only issue being that as you've already said, Mike, is that the rows out of view don't have column d populated until scrolled into view. I've now got around that in the AggregateCustomSummary with the following line of code (sorry not sure how to insert code in reply like you've done):
If row.Cells("d").Value Is Nothing Then row.Cells("d").Value = CDec(row.Cells("a").Value) + CDec(row.Cells("b").Value)
This does mean the formula is sort of duplicated within the code but never mind. There may be a better / more robust way of updating the cell value or testing that it's not been calculated and if so I'd be grateful for advice on that.
Once again thanks for all your help and I think it's time to move on....