Wijmo 5 - AngularJS directives
HTML
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="http://cdn.wijmo.com/5.20152.70/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.20152.70/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.20152.70/controls/wijmo.chart.min.js"></script>
<link rel="stylesheet" href="http://cdn.wijmo.com/5.20152.70/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.20152.70/interop/angular/wijmo.angular.min.js"></script>
<script src="http://cdn.wijmo.com/5.20152.90/controls/wijmo.grid.min.js"></script>
<!-- mark this as an Angular application and give it a controller -->
<div ng-app="app" ng-controller="appCtrl">
<h1>Hello Wijmo 5 and AngularJS!</h1>
<p>This is a <b>FlexGrid</b> control:</p>
<wj-flex-grid control="flex" items-source="cvGroup" selection-mode="Row"
selection-changed='selectionChanged(s,e)' item-formatter='formatItem(s,e)' cell-edit-ending='cellEditEnding(s,e)' lost-focus='lostFocus(s,e)' beginning-edit='beginEdit(s,e)' cell-edit-ended='cellEditEnded(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) {
// data context
$scope.ctx = {
flex: null
};
// create some random data
var countries = 'US,Germany,Netherlands,UK,Japan,Italy,Greece,Belgium,Iceland,Philippines'.split(','),
salesareas = 'East,West,North,South'.split(','),
data = [];
for (var i = 0; i < countries.length; i++) {
for (var j = 0; j < salesareas.length; j++) {
data.push({
country: countries[i],
salesarea: salesareas[j],
downloads: Math.round(Math.random() * 20000),
sales: Math.random() * 10000,
expenses: Math.random() * 5000
});
};
}
// expose data as a CollectionView to get events
$scope.cvGroup = new wijmo.collections.CollectionView(data);
var cv = $scope.cvGroup;
var groupDesc = new wijmo.collections.PropertyGroupDescription("country");
cv.groupDescriptions.push(groupDesc);
//cv.collapseGroupsToLevel(1);
$scope.cellEditEnding =
function(s, e) {
console.log('cell edit ending '+e.row+' '+e.col);
};
// log selection changes
$scope.selectionChanged = function(s, e) {
console.log("sel "+e.row+" "+e.col);
$scope.flex.startEditing(true, e.row, e.col);
};
// log selection changes
$scope.lostFocus = function(s, e) {
s.select(-1,-1);
};
$scope.beginEdit = function(s, e) {
console.log($scope);
console.log("cell begin edit "+e.row+" "+e.col);
e.panel.rows[e.row].height = e.panel.rows[e.row].renderHeight *5;
};
$scope.cellEditEnded = function(s, e) {
console.log("cel edit ended "+e.row+" "+e.col);
e.panel.rows[e.row].height = e.panel.rows[e.row].renderHeight / 5;
};
$scope.formatItem =...