Posted 13 October 2020, 6:48 am EST
Is there a way to enable undo/redo to work with more functionality, e.g. cell borders, cell types, text alignment/format/size etc?
Forums Home / Spread / SpreadJS
Posted by: brian on 13 October 2020, 6:48 am EST
Posted 13 October 2020, 6:48 am EST
Is there a way to enable undo/redo to work with more functionality, e.g. cell borders, cell types, text alignment/format/size etc?
Posted 14 October 2020, 7:21 pm EST
Hello Brian,
For this, we need to define custom commands to set cell borders, text alignment etc.
Please refer to the following code snippet for reference:
https://www.grapecity.com/spreadjs/demos/features/worksheet/actions/custom-action/purejs
Regards,
Manish Gupta
Posted 28 May 2021, 4:16 am EST
Hi Manish,
We would like this to apply to all possible actions - is there not a more generic way of achieving this, instead of creating custom commands for every single possible action? That would be quite a bit of work
Posted 28 May 2021, 4:18 am EST
For your reference, we based our application off of this sample: https://www.grapecity.com/spreadjs/spreadsheet/
Posted 30 May 2021, 6:24 pm EST
Hi Brian,
We are sorry but there no other way to acheive this functionality. You need to create a command for each action. We are sorry for the inconvenience.
Regards
Avinash
Posted 2 June 2021, 3:30 am EST
Hi Avinash, I am setting up the custom commands and I noticed in some examples that the custom commands could be set to inherit from GC.Spread.Sheets.UndoRedo.ActionBase so that I could do something like this:
function CustomActionBase(spread) {
this._spread = spread;
...
}
CustomActionBase.prototype = UndoRedo.ActionBase.prototype;
CustomActionBase.prototype.constructor = UndoRedo.ActionBase;
So that I could then use that as a basis for all of my custom commands. However, I can not seem to find where GC.Spread.Sheets.UndoRedo.ActionBase is imported from. Could you please advise on this?
Posted 3 June 2021, 12:09 am EST
Hi Brian,
The SpreadJS does not publish any public API as GC.Spread.Sheets.UndoRedo.ActionBase , register commands using the command manager would be the recommended way to acheive the required functionality. Please refer to the following demo that demonstrates the same.
CustomAction Demo: https://www.grapecity.com/spreadjs/demos/features/worksheet/actions/custom-action/purejs
Regards
Avinash
Posted 14 June 2021, 9:49 am EST
Hi Avinash, I’m referring to the blog post here:
https://www.grapecity.com/blogs/adding-undoredo-to-a-ribbon-with-spreadjs
Posted 14 June 2021, 5:54 pm EST
Hi Brian,
This is a blog based on the very much old version of SpreadJS. Now the API has been changed a lot since then. SpreadJS provides a command manager for creating action.
Hope this clarifies the issue.
CustomAction Demo: https://www.grapecity.com/spreadjs/demos/features/worksheet/actions/custom-action/purejs
Regards
Avinash