Wijmo 5 - AngularJS directives
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.grid.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.chart.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/interop/angular/wijmo.angular.min.js"></script>
<!--Some Toolbar -->
<!-- mark this as an Angular application and give it a controller -->
<div ng-app="app" ng-controller="appCtrl" class="container">
<!--WJ Group Panel -->
<wj-flex-grid ng-mouseleave="onMouseLeave($event)" ng-mouseover="onMouseOver($event)" items-source="data" control="grid">
<wj-flex-grid-column header="Country" binding="country"></wj-flex-grid-column>
<wj-flex-grid-column header="Sales" binding="sales">
</wj-flex-grid-column>
<wj-flex-grid-column header="Expenses" binding="expenses"></wj-flex-grid-column>
<wj-flex-grid-column header="Downloads" binding="downloads"></wj-flex-grid-column>
</wj-flex-grid><br>
</div>
CSS
.wj-flexgrid {
height: 450px;
width: auto;
margin-bottom: 20px;
}
body {
margin: 40px;
}
TypeScript
// define app, include Wijmo 5 directives
var app = angular.module('app', ['wj']);
// controller
app.controller('appCtrl', function($scope) {
$scope.grid = null;
var tooltip = new wijmo.Tooltip();
$scope.onMouseOver = function(e) {
if ($scope.grid)
{
var hti = $scope.grid.hitTest(e);
if(hti.panel && hti.panel.cellType === wijmo.grid.CellType.ColumnHeader) {
var header = hti.panel.getCellData(hti.row, hti.col, false);
var ele = hti.panel.getCellElement(hti.row, hti.col);
//Some Custom Logic Required as Tooltips dynamcially loading
for (var i = 0; i < $scope.grid.columns.length; i++) {
if ($scope.grid.columns[i].header === header) {
tooltip.show(ele, $scope.grid.columns[i].header); //Instead of header content I am using i.e this.$scope.ctx.columns[i].tooltipcolumn
return;
}
}
}
else {
tooltip.hide();
}
}
}
//Here I am using MouseLeave since, my Version is Diferent.
$scope.onMouseLeave = function(e) {
tooltip.hide();
}
// create some random data
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
data = [];
for (var i = 0; i < 200; i++) {
data.push({
country: countries[i % countries.length],
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.autoSize = function() {
$scope.grid.autoSizeRows();
$scope.grid.autoSizeColumns();
}
});