Hi Kendo UI Team
I'm trying to customize my kendo spreadsheet and I am trying to find a way to clear a user's undo/redo history on a button click. I also want to do this without losing the undo/redo functionality. I noticed that there is an undoRedoStack in
$('#SpreadsheetName').data("kendoSpreadsheet")._workbook, but when I
pop from this undoRedoStack it gives an error when the user tries to undo/redo again.
Is there a way to clear
the undo history in the spreadsheet?
Many thanks,
Jeff
5 Answers, 1 is accepted
Currently there is no built-in functionality (configuration option or API method) for clearing the undo/redo history so we would recommend logging this as a feature request in our Feedback Portal. Here you can find a dojo example, in which the default undo/redo buttons are clicked with jQuery based on two counters simulating a similar history clearing behavior.
Regards,
Ivan Danchev
Progress Telerik
Hi,
For anyone curious, my team took the above dojo example and modified to suit our original needs - you can see the results of our changes here: http://dojo.telerik.com/ECOTO/8
However this does not account for user keyboard input shortcuts like CTRL+Z/Y
Thus, we have a followup question that is related - but for some reason I am unable to make a new thread for it so I will ask it here and hopefully someone picks up on it:
I'm looking to prevent or override the Spreadsheet's undo and redo keyboard shortcut functionality (CTRL+Z and CTRL+Y) while keeping the undo and redo buttons and respective functionality. I would also like to keep the other shortcuts (CTRL+C, CTRL+P, CTRL+V, etc).
I have the following code
which allows me to do my custom undo/redo shortcut functions, however it does not prevent
Spreadsheet's default CTRL+Z and CTRL+Y behavior.
// Capture
Ctrl Z and Ctrl Y then sync undo/redo counters (doStuff())
$(document).keydown(function (e) {
// Ctrl Z
if (e.ctrlKey
&& e.keyCode == 90) {
preventdefault(e)
doStuff();
}
// Ctrl Y
else if
(e.ctrlKey && e.keyCode == 89) {
preventdefault(e)
doStuff();
}
});
Many thanks,
Jeff
The Spreadsheet performs the undo/redo actions prior to this code being executed:
if
(e.ctrlKey && e.keyCode == 90) {
preventdefault(e)
doStuff();
}
// Ctrl Y
else
if
(e.ctrlKey && e.keyCode == 89) {
preventdefault(e)
doStuff();
}
Regards,
Ivan Danchev
Progress Telerik
Hi,
When you say that the event that gives control over these actions is not exposed, you mean that we cannot customize it at all right? However, would it be possible rather than customizing the undo event for us to instead simply completely remove the undo/redo keyboard shortcuts functionality?
Thanks,
Jeff
I meant that by the time $(document).keydown(function(e) { ... }); fires the Spreadsheet has executed the undo/redo operation internally and that it does not expose a specific event in its API related to the undo/redo functionality that you can handle/prevent. There is no configuration options for enabling/disabling the triggering of the undo/redo operations with the keyboard, thus achieving this would require modifying the source code.
Regards,
Ivan Danchev
Progress Telerik