Wijmo 5 - Tab Key

HTML

<script src="http://cdn.wijmo.com/5.20143.27/controls/wijmo.min.js"></script>
<link rel="stylesheet" href="http://cdn.wijmo.com/5.20143.27/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.20143.27/controls/wijmo.grid.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
<script src="http://cdn.wijmo.com/5.20143.27/interop/angular/wijmo.angular.min.js"></script>
<div ng-app="app" ng-controller="appCtrl">
    
    <input type="text"/>
    <p>Wijmo <b>FlexGrid</b> 
    </p>
    <wj-flex-grid items-source="data" control="flex">
        <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>
</div>

JavaScript

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

  // controller
  app.controller('appCtrl', function ($scope) {

      // create some random data
      var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
          data = new wijmo.collections.ObservableArray();
      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,
              dateInput: '/Date(1365715800000)/'
          });
      }

      // expose data as a CollectionView to get events
      $scope.data = new wijmo.collections.CollectionView(data);

      $scope.$watch('flex', function () {

          var flex = $scope.flex;
          if (flex) {
           
              var host = flex.hostElement;
              //handle the keydown event
              host.addEventListener('keydown', function (e) {
                  //check for 'Tab' key
                  if (e.which == 9) {
                      //get the current selection
                      var selectedCellRange = flex.selection;
                       //if the selected column is the first column then ignore it 
                      if (flex.selection.col == 0) {
                          selectedCellRange.col = selectedCellRange.col + 1;
                          flex.select(selectedCellRange, true);
                      }
                      //put the cell in edit mode
                      flex.startEditing(false, flex.selection.row, flex.selection.col);
                  }
              });

          }
      });
  });