Wijmo 5 - WjFlexGrid advanced 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/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" class="container">
<h1>WjFlexGrid directive</h1>
<p>This is a <b>FlexGrid</b> control:</p>
<wj-flex-grid items-source="data" selection-mode="Row">
<wj-flex-grid-column header="Name" binding="name" is-read-only="true" width="2*">
<span ng-style="background-color:{{$item.color}}">
</span>
{{$item.name}}
</wj-flex-grid-column>
<wj-flex-grid-column header="Symbol" binding="symbol" is-read-only="true" width="*">
<a href="https://finance.yahoo.com/q?s={{$item.symbol}}">
<b>{{$item.symbol}}</b>
</a>
</wj-flex-grid-column>
<wj-flex-grid-column header="Last Price" binding="price" format="n2" width="*">
</wj-flex-grid-column>
<wj-flex-grid-column header="Change" binding="change" format="p2" width="*"
ng-style="{color:getAmountColor($item.change)}">
</wj-flex-grid-column>
</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 data
$scope.data = [
{ name: 'Apple Inc', symbol: 'AAPL', price: 98.38, change: -0.35, color: 'red' },
{ name: 'Amazon.com, Inc.', symbol: 'AMZN', price: 320.00, change: +.23, color: 'green' },
{ name: 'Google Inc.', symbol: 'GOOG', price: 585.81, change: -0.54, color: 'blue' },
{ name: 'Yahoo Inc.', symbol: 'YHOO', price: 35.68, change: -0.31, color: 'orange' }
];
// show positive values in green, negative in red
$scope.getAmountColor = function(amount) {
return amount < -0.01 ? '#9F3912' : amount > 0.01 ? '#217648' : '#b0b0b0';
}
});