Hi Team,
Is there any icon’s for redo and undo in grid js aspose cells for python via dotnet.
Cause
Currently, Aspose.Cells for Python via .NET does not provide built-in icons specifically for undo and redo actions in the Grid JS component. However, you can implement these functionalities manually.
Solution
To implement undo and redo functionality, you can maintain a stack of actions performed on the grid. Each time an action is performed, you push it onto the undo stack. For redo, you can maintain another stack to keep track of actions that have been undone.
Code
Here’s a basic example of how you might implement this:
class GridActions:
def __init__(self):
self.undo_stack = []
self.redo_stack = []
def perform_action(self, action):
self.undo_stack.append(action)
self.redo_stack.clear() # Clear redo stack on new action
def undo(self):
if self.undo_stack:
action = self.undo_stack.pop()
self.redo_stack.append(action)
# Code to revert the action
print(f"Undid action: {action}")
def redo(self):
if self.redo_stack:
action = self.redo_stack.pop()
self.undo_stack.append(action)
# Code to reapply the action
print(f"Redid action: {action}")
# Example usage
grid_actions = GridActions()
grid_actions.perform_action("Edit Cell A1")
grid_actions.undo()
grid_actions.redo()
Next Steps
- Integrate the above logic into your grid component.
- Create UI buttons for undo and redo actions and link them to the respective methods.
- Test the implementation thoroughly to ensure it meets your requirements.
If you have any further questions or need additional assistance, please feel free to ask!
Can we implement custom logic by adding two buttons — one for Undo and one for Redo — and use them to call functions from xspreadsheet.js
to perform the respective actions?
@sarathepiq
We haven’t implemented the undo/redo functions yet.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSGRIDJS-1770 Support undo/redo in GridJs
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
while click ctrl + z we are able to do undo
ctrl + y we are able to perform redo .
is this logic existed in xspreadsheet.js
I observed below logic in xspreadsheet.js
{
key: “undo”, value: function () {
var e = this;
this.history.undo((function (t) {
return e.getRangeData(t.range)
}), (function (t) {
e.setRangeData(t)
}))
}
}, {
key: “redo”, value: function () {
var e = this;
this.history.redo((function (t) {
return e.getRangeData(t.range)
}), (function (t) {
e.setRangeData(t)
}))
}
},
@sarathepiq
We have implemented a basic code framework; however, the undo/redo functionality is still incomplete.