Wijmo 5 [FlexGrid]
Update cellValue on serviceCall
HTML
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.wijmo.com/5.20172.328/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.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.20172.328/interop/angular/wijmo.angular.min.js"></script>
<!-- mark this as an Angular application and give it a controller -->
<div ng-app="app" ng-controller="appCtrl">
<h1>Update Cell value after serverCalculation</h1>
<p>This is a <b>FlexGrid</b> control.Edit Downlaod Column cell, updated cell will be updated on server respose only when FlexGrid cell is not in edit mode</p>
<wj-flex-grid items-source="data" initialized="initialized(s,e)">
</wj-flex-grid>
</div>
JavaScript
// define app, include Wijmo 5 directives
var app = angular.module('app', ['wj']);
// controller
app.controller('appCtrl', function($scope) {
// create some random data
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.random() * 10000,
expenses: Math.random() * 5000
});
}
// expose data as a CollectionView to get events
$scope.data = new wijmo.collections.CollectionView(data);
$scope.initialized = function(s, e) {
s.cellEditEnding.addHandler(function(s, e) {
var val = s.activeEditor.value;
var src=s.collectionView,
binding=s.columns[e.col].binding,
index= src.sourceCollection.indexOf(src.currentItem);
// make service call
setTimeout(function() {
if (e.col == 1) {
src.sourceCollection[index][binding]=isDownloadValid(val);
if(s.editRange==null){
s.refresh();
}
}
}, 3000);
});
function isDownloadValid(value) {
if (value > 100) {
return value * 5;
}
return value + 100;
}
}
});