Posted 29 November 2017, 2:13 am EST
Created a sheet where ctrl+z is working fine whenever we edit the data. But if i am change the text to italic,bold,underline the data doesn;t get undo.
How do i do that?
$scope.keycharcode = function(e) {
$scope.keyCode = e.which;
if (e.ctrlKey && $scope.keyCode == 66){
buttonShortcut(“bold”);
}
else if (e.ctrlKey && $scope.keyCode == 73){
buttonShortcut(“italic”);
}
else if (e.ctrlKey && $scope.keyCode == 90){
var sheet = spreadsheet.activeSheet();
var range = sheet.selection();
var values = range.values();
buttonShortcut(“undo”);
}
This is how trying to call the spread.allowUndo(True) method in js file.
function buttonShortcut(shortcutname) {
var $element = $(this),
name = shortcutname,
container;
var sheet = spread.getActiveSheet();
switch (name) {
case "bold":
setStyleFont(sheet, "font-weight", ["700", "bold"], "normal");
break;
case "italic":
setStyleFont(sheet, "font-style", ["italic"], "normal");
break;
case "underline":
setTextDecoration(sheet, spreadNS.TextDecorationType.Underline);
break;
case "strikethrough":
setTextDecoration(sheet, spreadNS.TextDecorationType.LineThrough);
break;
case "overline":
setTextDecoration(sheet, spreadNS.TextDecorationType.Overline);
break;
case "increaseIndent":
setTextIndent(sheet, 1);
break;
case "decreaseIndent":
setTextIndent(sheet, -1);
break;
case "percentStyle":
setFormatter(uiResource.cellTab.format.percentValue);
break;
case "commaStyle":
setFormatter(uiResource.cellTab.format.commaValue);
break;
case "increaseDecimal":
increaseDecimal();
break;
case "decreaseDecimal":
decreaseDecimal();
break;
case "undo":
undo(); //this function calls the below function.
break;
…
function undo()
{
spread.allowUndo(true);
//var sheet = spread.getActiveSheet();
// GcSpread.Sheets.SpreadActions.undo.apply(sheettest);
}
How do i hold the value of the cell before editing it and after changing the value i get back once i press ctrl+z.