Wijmo 5 [CustomEditor]

HTML

<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.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.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/interop/angular/wijmo.angular.min.js"></script>
<div ng-app="app">
  <div ng-controller="appCtrl">
    <button ng-click="updateId()">
    Update ID
  </button>
    <wj-flex-grid item-formatter='formatter' auto-size-rows="0" items-source="data" item-formatter="itemFormatter" control="flex">
      <wj-flex-grid-column header="Id" binding="id">
        <wj-flex-grid-cell-template cell-type="Cell">
          <div title="{{titleValue}}" ng-controller="displayCellCtrl">
            {{displayValue}}
            <button ng-mousedown="openDialog()" style="float:right;">
            Alert
            </button>
          </div>
        </wj-flex-grid-cell-template>
        <wj-flex-grid-cell-template cell-type="CellEdit">
          <input ng-model="$value"></input>
        </wj-flex-grid-cell-template>
      </wj-flex-grid-column>
      <wj-flex-grid-column header="Country" binding='country'>
        <wj-flex-grid-cell-template cell-type="CellEdit">
          <wj-combo-box items-source="countries" ng-model="$value"></wj-combo-box>
        </wj-flex-grid-cell-template>
      </wj-flex-grid-column>
      <wj-flex-grid-column header="Sales" binding="sales"></wj-flex-grid-column>
      <wj-flex-grid-column header="Downloads" binding="downloads"></wj-flex-grid-column>
      <wj-flex-grid-column header="Active" binding="active"></wj-flex-grid-column>
    </wj-flex-grid>

  </div>

JavaScript

var getData = function(value) {
    var countries = 'India,Japan,UK,US,China'.split(','),
      data = [];
    for (var i = 0; i < value; i++) {
      data.push({
        id: i + 1,
        country: countries[i % countries.length],
        sales: Math.random() * 10000,
        downloads: Math.random() * 200,
        active: i % 3 == 0
      });
    }
    return data;
  };


  var app = angular.module('app', ['wj']);
  app.controller('appCtrl', function($scope) {
    /* $scope.formatter = function(panel, r, c, cell) {
      if (panel.cellType == 1 && panel.grid.columns[c].binding == 'id') {
        if (panel.grid.activeEditor && (panel.grid.editRange.row == r && panel.grid.editRange.col == c)) {
          return;
        }
        //do formatting here
    
        var curValue = panel.grid.rows[r].dataItem.id;
        var calculatedValueForDisplay = "$ " + curValue * 2 + " twice";
        cell.innerText = calculatedValueForDisplay;
    
      }
    }; */

    $scope.data = new wijmo.collections.CollectionView(getData(9));
    $scope.countries = 'India,Japan,UK,US,China'.split(',');

    $scope.updateId = function() {
      $scope.data.items[0].id = null;
      $scope.flex.refresh();
    }
  });

  app.controller('displayCellCtrl', function($scope) {
    $scope.openDialog = function() {
      alert($scope.$item.id+"  "+$scope.displayValue); 
    }
    
    $scope.$watch('$item',function(newItem,oldItem){
    	$scope.displayValue = $scope.$item && $scope.$item.id ? $scope.$item.id : customValue;
    },true);
    
    var customValue = "Server Call Value";
    $scope.displayValue = $scope.$item && $scope.$item.id ? $scope.$item.id : customValue;
    $scope.titleValue = $scope.displayValue + " and other information";
  });