Wijmo FlexSheet (282)

non-editable cells wijmo build 282

by Joel Parks

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.wijmo.com/5.20171.282/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.20171.282/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.20171.282/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.20171.282/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.20171.282/controls/wijmo.grid.filter.min.js"></script>
<script src="http://cdn.wijmo.com/5.20171.282/controls/wijmo.grid.sheet.min.js"></script>
<div class="container">
<p>
 This FlexSheet sample uses the <b>beginningEdit</b> event to apply Read-Only cells in the "Downloads" column.
 </p>
 <p>
 The Read-Only cells are only in the odd-numbered rows.
 </p>
 <p>This sample uses build<b> #282</b></p>
 <div id="flexSheet" style="height:300px;"></div>
 </div>

JavaScript

var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
    data = [],
		bigList = ['US', 'Germany', 'UK', 'Japan', 'Italy', 'Greece'];
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', {
		itemFormatter: function(s, e){
			var column = s.columns.getColumn('country');
			if(column && !column.dataMap){
				column.dataMap = buildDataMap(bigList);
			}
		},
});

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

flexSheet.beginningEdit.addHandler(function (s, e) {
  var col = s.columns[e.col];
  if (col.binding == 'downloads' && e.row%2 == 0) {
     e.cancel = true;
  }
});

function buildDataMap(list){
	var map = [];
	console.log(list);
	for(var i = 0; i < list.length; i++){
		map.push({ key: i, value: list[i] })
		return new wijmo.grid.DataMap(map, 'key', 'value');
	}
}