FlexSheet

Prevent Undo/Redo actions & updating UndoStack

by Troy Taylor

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>
   applyCellsStyle does not persist sometimes after sorting</p>
   <h4>
   Repro Steps:
   </h4>
   <ol>
     <li>Insert a Row</li>
     <li>Select cell in new row and click "Apply Style to Cell" button</li>
     <li>Sort any column using Filter Dialog</li>
     <li>Repeat above steps and the second time the applied style will be removed after clicking button</li>
   </ol>
 <br>
 <button type="button" id="styleButton" onclick="applyCellStyle()">
 Apply Style to Cell
 </button><br><br>
 <div id="flexSheet" style="height:400px;"></div>
 
 </div>

CSS

.wj-flexsheet .wj-header-row {

        background-color: #808080 !important;

}

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');
setTimeout( function () {
  flexSheet._rows[0].height = 60;
}, 100);

flexSheet.updatingLayout.addHandler(function(s,e) {
	console.log('updatingLayout');
});

flexSheet.updatedLayout.addHandler(function(s,e) {
	console.log('updatedLayout');
});

/* flexSheet.refreshed.addHandler(function(s,e) {

  console.log('refreshed');
    if (s.selectedSheetIndex == 0){    
      //resize all rows row
      //s.rows.defaultSize = 60;
      console.log('resizing header row height');
      
      //customer's code
      if (s._rows.length > 0) {
        s._rows[0].height = 60;
        s.frozenRows = 1;
      }
    }
  
}); */


// 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);

function applyCellStyle () {
  flexSheet.applyCellsStyle({backgroundColor: "yellow"}, false);
}