Wijmo (Angular) - Multi-Item Dropdown in FlexGrid

Inserts more than 4 items in the FlexGrid dropdown.

by Joel Parks

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.latest/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.chart.min.js"></script>
<script src="http://cdn.wijmo.com/5.20161.138/controls/wijmo.grid.filter.min.js"></script>
<script src="http://cdn.wijmo.com/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">
  <div ng-hide="hidden">
    <wj-flex-grid items-source="data"  item-formatter="itemFormatter" style="height: 400px;margin-top:10px" control="flex">
      <wj-flex-grid-filter></wj-flex-grid-filter>
      <!--THE DATA-MAP PROPERTY ASSIGNS THE DATA MAP CREATED IN THE JAVASCRIPT FILE TO THIS COLUMN-->
      <wj-flex-grid-column header="Country" binding="country" width="*" data-map="countryMap" drop-down-css-class="dropdown"></wj-flex-grid-column>
      <wj-flex-grid-column header="Expenses" binding="expenses" format="c" width="*"></wj-flex-grid-column>
      <wj-flex-grid-column header="Sales" name="Sales"  binding="sales" format="c" width="*">
        <span style="color:green" ng-if="$item.sales > 5000">{{ $item.sales | currency}}</span> 
        <span style="color:red" ng-if="$item.sales < 5000">{{ $item.sales | currency}}</span> 
      </wj-flex-grid-column>
      <wj-flex-grid-column header="Date" binding="date" format="dd/MM/yyyy"></wj-flex-grid-column>
    </wj-flex-grid>
  </div>
</div>

CSS

.dropdown{
  min-height: 230px;
}

JavaScript

// define app, include Wijmo 5 directives
var app = angular.module('app', ['wj']);

// controller
app.controller('appCtrl', function ($scope) {
//	$scope.itemFormatter = itemFormatter;
	    // create some random data
    var countries = 'Australia, China'.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,
            date: new Date(2016, i % 12, (i + 10) % 25),
        });
    }
		
    // expose data as a CollectionView to get events
    $scope.data = new wijmo.collections.CollectionView(data);
    
    $scope.logLevelList = ['Fatal', 'Error', 'Warn', 'Info', 'Debug'];
  	$scope.logLevels = ['Fatal', 'Error'];
    $scope.customCellEdit = true;
  
  	$scope.initControl = function(s, e) {

		// monitor changes
    s.checkedItemsChanged.addHandler(function() {
    	console.log('test');
      //$scope.checkedItems = s.checkedItems;
			//$scope.$apply();
		});

  	// initialize checked items
    s.checkedItems = $scope.logLevels;
	}
  
  // CREATES THE DATAMAP OF COUNTRIES TO BE USED IN THE FLEXGRID
  var countryMap = [
  	{name: 'US', key: 0},
    {name: 'Germany', key: 1},
    {name: 'Japan', key: 2},
    {name: 'Italy', key: 3},
    {name: 'Greece', key: 4},
    {name: 'Spain', key: 5},
    {name: 'Chile', key: 6},
    {name: 'China', key: 7},
    {name: 'Canada', key: 8},
  ];
  
  $scope.countryMap = new wijmo.grid.DataMap(new wijmo.collections.CollectionView(countryMap), 'key', 'name');
});