Wijmo 5 [Flex Grid]
Highlight edited cell manually/pasted data using itemformatter
by Manas
HTML
<link rel="stylesheet" href="http://cdn.wijmo.com/5.20173.380/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.20173.380/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.20173.380/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.20173.380/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.20173.380/interop/angular/wijmo.angular.min.js"></script>
<div ng-app="app" ng-controller="appCtrl" >
<wj-flex-grid items-source="data" initialized="init(s,e)">
</wj-flex-grid>
</div>
<input type="submit" value = "chk" name= "chk" ng-click="a()">
JavaScript
var app = angular.module('app', ['wj']);
// app controller provides data
app.controller('appCtrl', function appCtrl($scope) {
// generate some random data
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
data = [];
for (var i = 0; i < 5; i++) {
data.push({
id: i,
country: countries[i % countries.length],
date: new Date(2014, i % 12, i % 28),
amount: Math.random() * 10000,
active: i % 4 == 0
});
}
// add data array to scope
$scope.data = data;
$scope.init = function(s, e) {
s.cellEditEnding.addHandler(function (s, e) {
if(s.getCellData(e.row,e.col)!==s.activeEditor.value){
setChanged(e.row, e.col);
}
});
s.pastingCell.addHandler(function (s, e) {
if(s.getCellData(e.row,e.col)!==e.data){
setChanged(e.row, e.col);
}
});
s.itemFormatter = function (panel, r, c, cell) {
if (panel.cellType == wijmo.grid.CellType.Cell) {
if (getChanged(r, c)) {
cell.style.backgroundColor = '#ADD8E6';
}
}
}
// utility to keep track of changed items
var changes = [];
function setChanged(r, c) {
if (!getChanged(r, c)) {
changes.push({
item: s.rows[r].dataItem,
prop: s.columns[c].binding,
...