FlexSheet

Prevent Undo/Redo actions & updating UndoStack

by c1alexi

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.filter.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.sheet.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.xlsx.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.xlsx.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.xlsx.min.js"></script>
 <div class="container">
   <h1>
   FlexSheet
   </h1>
   <p>
   <b>addFunction</b> method does throws an error when a function that accepts no parameters is entered in a cell of FlexSheet.
   </p>
 <br>
 <div id="flexSheet" style="height:400px;"></div>
 
 </div>

JavaScript

var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
    data = [];
for (var i = 0; i < countries.length; i++) {
    data.push({
        country: countries[i],
        downloads: Math.round(Math.random() * 20000),
        sales: Math.round(Math.random() * 10000),
        expenses: Math.round(Math.random() * 5000)
    });
}

// create the FlexSheet control
var flexSheet = new wijmo.grid.sheet.FlexSheet('#flexSheet');

function func (...args)  {
	return 1;
}
//flexSheet.addFunction("test", func, "this is a test", 0, 1);
flexSheet.addFunction("test", func, "this is a test");



// create and add a new sheet the control
var sheet = new wijmo.grid.sheet.Sheet();
sheet.name = "New Sheet";
sheet.itemsSource = data;
flexSheet.sheets.push(sheet);

// push a new empty sheet onto the sheets array
var emptysheet = new wijmo.grid.sheet.Sheet(flexSheet, null, "Empty Sheet")
flexSheet.sheets.push(emptysheet);

flexSheet.hostElement.addEventListener("keydown", function (e) {
	console.log(e.keyCode);
	if (e.ctrlKey && (e.keyCode === 90 || e.keyCode === 89) && wijmo.contains(flexSheet.hostElement, e.target)) {
    e.preventDefault();
    e.stopPropagation();
    console.log(flexSheet.undoStack);
  }
}, true);