Multiple Undo/Redo with Formula cells

I am using the Grid Control v3.201.1.1 The default Undo/Redo works with formula cells, but you have to call Undo many times (at least one time for each affected formula cell) to undo one change. I have read your response to correct this problem by using transactions which are started and committed in the cellmove event. I have not been able to get this to work. It works fine to undo one change, but when there are multiple changes it does not seem to work. After the first transaction is rolled back, the CommandStack is no longer in a transaction even though the top item on the stack is another transaction. I have to manually undo the stack until I reach the next transaction, which works somewhat, but i think it defeats the purpose of the transactions. The redo does not work with this approach. My current approach is to enable the CommandStack on CurrentCellStartEditing, and disable it on CurrentCellEditingComplete. This works great for Undo, but the Redo does not work at all. I have tried to manually push the undo command to the RedoStack at the time of the Undo, and this will put items on the RedoStack, but when I Redo only cell moves are restored, not the cell value. I know I am not the only person with this problem. Would it be possible to get a sample of how to do this correctly? My test app has two formula cells. B1=A1+A2+A3, and C1=B1/2. I enter values in A1 through A3 to test undo/redo. Thanks Per

6 Replies

AD Administrator Syncfusion Team June 24, 2005 07:44 PM UTC

My approach of enabling the CommandStack only when I wish to record events works flawlessly for Undo with formula cells, including paste events that affect formula cells. The Redo however is not working at all with this approach. It moves the current cell around the grid for each Redo, but does not restore any data in the cells. >I am using the Grid Control v3.201.1.1 > >The default Undo/Redo works with formula cells, but you have to call Undo many >times (at least one time for each affected formula cell) to undo one change. > >I have read your response to correct this problem by using transactions which >are started and committed in the cellmove event. I have not been able to get this >to work. It works fine to undo one change, but when there are multiple changes >it does not seem to work. After the first transaction is rolled back, >the CommandStack is no longer in a transaction even though the top item on >the stack is another transaction. I have to manually undo the stack until >I reach the next transaction, which works somewhat, but i think it defeats the purpose >of the transactions. The redo does not work with this approach. > >My current approach is to enable the CommandStack on CurrentCellStartEditing, and >disable it on CurrentCellEditingComplete. This works great for Undo, but the >Redo does not work at all. I have tried to manually push the undo command to >the RedoStack at the time of the Undo, and this will put items on the RedoStack, >but when I Redo only cell moves are restored, not the cell value. > >I know I am not the only person with this problem. Would it be possible to >get a sample of how to do this correctly? > >My test app has two formula cells. B1=A1+A2+A3, and C1=B1/2. >I enter values in A1 through A3 to test undo/redo. > >Thanks > >Per


AD Administrator Syncfusion Team June 25, 2005 09:05 AM UTC

Checking our source code, the formula engine explicitly disables the CommandStack in two places. One is when references are adjusted after a formula has been moved (as in a copy/paste or row/col insert/remove) and the other is when dependent cells are being refreshed. I suspect this latter code is why your redo is not being performed. We will add a property to the engine to allow you to control whether the command stack is disabled. This may allow your technique to work. If you upload a little sample using your technique, we can try it here with the modifed library code to see if there is anything else we need to do to get it working.


AD Administrator Syncfusion Team June 27, 2005 01:30 PM UTC

Thanks for your response. I have attached my test project as you requested. If you have a suggestion for any other approach such as the transactions you have mentioned before I’d be interested to give that another try. Like I mentioned before, I was not able to make it work, but I may have been doing something wrong. What is the time frame to get the fix you mentioned, assuming that my technique works with it? Thanks for your help! Per >Checking our source code, the formula engine explicitly disables the CommandStack in two places. One is when references are adjusted after a formula has been moved (as in a copy/paste or row/col insert/remove) and the other is when dependent cells are being refreshed. I suspect this latter code is why your redo is not being performed. > >We will add a property to the engine to allow you to control whether the command stack is disabled. This may allow your technique to work. If you upload a little sample using your technique, we can try it here with the modifed library code to see if there is anything else we need to do to get it working. PerUndo_8597.zip


AD Administrator Syncfusion Team July 11, 2005 09:51 PM UTC

Clay, Did you have a chance to look at this yet? Thanks, Per >Thanks for your response. I have attached my test project as you requested. > >If you have a suggestion for any other approach such as the transactions you have mentioned before I’d be interested to give that another try. Like I mentioned before, I was not able to make it work, but I may have been doing something wrong. > >What is the time frame to get the fix you mentioned, assuming that my technique works with it? > >Thanks for your help! > >Per > > > >>Checking our source code, the formula engine explicitly disables the CommandStack in two places. One is when references are adjusted after a formula has been moved (as in a copy/paste or row/col insert/remove) and the other is when dependent cells are being refreshed. I suspect this latter code is why your redo is not being performed. >> >>We will add a property to the engine to allow you to control whether the command stack is disabled. This may allow your technique to work. If you upload a little sample using your technique, we can try it here with the modifed library code to see if there is anything else we need to do to get it working. > >PerUndo_8597.zip > >


AD Administrator Syncfusion Team July 12, 2005 12:31 PM UTC

Per, Sorry for the delay. I will update this later today or tomorrow. Clay


AD Administrator Syncfusion Team July 13, 2005 11:06 AM UTC

Here is your sample back. I think I was able to get the user changing cells redo/undo to work back and forth using your idea of turning the CommandStack on and off as the cell is actively being edited. I think the main problem was the undo information was pointing to the wrong cell. To get things working, I added a derived SyncfusionCommand class (ChangeCells) that is used for the commands that are added to the Redo stack so that things are pointed at the proper cell. http://www.syncfusion.com/Support/user/uploads/PerUndo_1d62ba99.zip In the long run, we will have to make adjustments to the undo/redo/formulaengine classes to handle undo/redo support in the formulaengine.

Loader.
Up arrow icon