src/features/edit/js/gridEdit.js
/**
             *  @ngdoc property
             *  @name editDropdownFilter
             *  @propertyOf ui.grid.edit.api:ColumnDef
             *  @description A filter that you would like to apply to the values in the options list
             *  of the dropdown.  For example if you were using angular-translate you might set this
             *  to `'translate'`
             *  @example
             *  <pre>
             *    $scope.gridOptions = {
             *      columnDefs: [
             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
             *          editDropdownOptionsArray: [{code: 1, status: 'active'}, {code: 2, status: 'inactive'}],
             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status', editDropdownFilter: 'translate' }
             *      ],
             *  </pre>
             *
             */
@ngdoc property
@name editDropdownFilter
@propertyOf ui.grid.edit.api:ColumnDef
@description A filter that you would like to apply to the values in the options list
of the dropdown.
@ngdoc property @name editDropdownFilter @propertyOf ui . grid . edit . api : ColumnDef @description A filter that you would like to apply to the values in the options list of the dropdown .
function beginEdit() {
              if (inEdit) {
                return;
              }
              if (!shouldEdit($scope.col, $scope.row)) {
                return;
              }
              cellModel = $parse($scope.row.getQualifiedColField($scope.col));
              origCellValue = cellModel($scope);
              html = $scope.col.editableCellTemplate;
              html = html.replace(uiGridConstants.MODEL_COL_FIELD, $scope.row.getQualifiedColField($scope.col));
              var optionFilter = $scope.col.colDef.editDropdownFilter ? '|' + $scope.col.colDef.editDropdownFilter : '';
              html = html.replace(uiGridConstants.CUSTOM_FILTERS, optionFilter);
              var inputType = 'text';
              switch ($scope.col.colDef.type) {
                  case 'boolean':
                  inputType = 'checkbox';
                  break;
                  case 'date':
                  inputType = 'date';
                  break;
              }
              html = html.replace('INPUT_TYPE', inputType);
              var mask = $scope.col.colDef.mask ? $scope.col.colDef.mask : '';
              html = html.replace('mask', mask);
              var editDropdownRowEntityOptionsArrayPath = $scope.col.colDef.editDropdownRowEntityOptionsArrayPath;
              if (editDropdownRowEntityOptionsArrayPath) {
                $scope.editDropdownOptionsArray =  resolveObjectFromPath($scope.row.entity, editDropdownRowEntityOptionsArrayPath);
              }
              else {
                $scope.editDropdownOptionsArray = $scope.col.colDef.editDropdownOptionsArray;
              }
              $scope.editDropdownIdLabel = $scope.col.colDef.editDropdownIdLabel ? $scope.col.colDef.editDropdownIdLabel : 'id';
              $scope.editDropdownValueLabel = $scope.col.colDef.editDropdownValueLabel ? $scope.col.colDef.editDropdownValueLabel : 'value';
              var cellElement;
              var createEditor = function(){
                inEdit = true;
                cancelBeginEditEvents();
                var cellElement = angular.element(html);
                $elm.append(cellElement);
                editCellScope = $scope.$new();
                $compile(cellElement)(editCellScope);
                var gridCellContentsEl = angular.element($elm.children()[0]);
                gridCellContentsEl.addClass('ui-grid-cell-contents-hidden');
              };
              if (!$rootScope.$$phase) {
                $scope.$apply(createEditor);
              } else {
                createEditor();
              }
              var deregOnGridScroll = $scope.col.grid.api.core.on.scrollBegin($scope, function () {
                endEdit(true);
                $scope.grid.api.edit.raise.afterCellEdit($scope.row.entity, $scope.col.colDef, cellModel($scope), origCellValue);
                deregOnGridScroll();
                deregOnEndCellEdit();
                deregOnCancelCellEdit();
              });
              var deregOnEndCellEdit = $scope.$on(uiGridEditConstants.events.END_CELL_EDIT, function (evt, retainFocus) {
                endEdit(retainFocus);
                $scope.grid.api.edit.raise.afterCellEdit($scope.row.entity, $scope.col.colDef, cellModel($scope), origCellValue);
                deregOnEndCellEdit();
                deregOnGridScroll();
                deregOnCancelCellEdit();
              });
              var deregOnCancelCellEdit = $scope.$on(uiGridEditConstants.events.CANCEL_CELL_EDIT, function () {
                cancelEdit();
                deregOnCancelCellEdit();
                deregOnGridScroll();
                deregOnEndCellEdit();
              });
              $scope.$broadcast(uiGridEditConstants.events.BEGIN_CELL_EDIT);
              $scope.grid.api.edit.raise.beginCellEdit($scope.row.entity, $scope.col.colDef);
            }
function beginEdit ( ) { if ( inEdit ) { return ; } if ( ! shouldEdit ( $scope . col , $scope . row ) ) { return ; } cellModel = $parse ( $scope . row . getQualifiedColField ( $scope . col ) ) ; origCellValue = cellModel ( $scope ) ; html = $scope . col . editableCellTemplate ; html = html . replace ( uiGridConstants . MODEL_COL_FIELD , $scope . row . getQualifiedColField ( $scope . col ) ) ; var optionFilter = $scope . col . colDef . editDropdownFilter ? '|' + $scope . col . colDef . editDropdownFilter : '' ; html = html . replace ( uiGridConstants . CUSTOM_FILTERS , optionFilter ) ; var inputType = 'text' ; switch ( $scope . col . colDef . type ) { case 'boolean' : inputType = 'checkbox' ; break ; case 'date' : inputType = 'date' ; break ; } html = html . replace ( 'INPUT_TYPE' , inputType ) ; var mask = $scope . col . colDef . mask ? $scope . col . colDef . mask : '' ; html = html . replace ( 'mask' , mask ) ; var editDropdownRowEntityOptionsArrayPath = $scope . col . colDef . editDropdownRowEntityOptionsArrayPath ; if ( editDropdownRowEntityOptionsArrayPath ) { $scope . editDropdownOptionsArray = resolveObjectFromPath ( $scope . row . entity , editDropdownRowEntityOptionsArrayPath ) ; } else { $scope . editDropdownOptionsArray = $scope . col . colDef . editDropdownOptionsArray ; } $scope . editDropdownIdLabel = $scope . col . colDef . editDropdownIdLabel ? $scope . col . colDef . editDropdownIdLabel : 'id' ; $scope . editDropdownValueLabel = $scope . col . colDef . editDropdownValueLabel ? $scope . col . colDef . editDropdownValueLabel : 'value' ; var cellElement ; var createEditor = function ( ) { inEdit = true ; cancelBeginEditEvents ( ) ; var cellElement = angular . element ( html ) ; $elm . append ( cellElement ) ; editCellScope = $scope . $new ( ) ; $compile ( cellElement ) ( editCellScope ) ; var gridCellContentsEl = angular . element ( $elm . children ( ) [ 0 ] ) ; gridCellContentsEl . addClass ( 'ui-grid-cell-contents-hidden' ) ; } ; if ( ! $rootScope . $$phase ) { $scope . $apply ( createEditor ) ; } else { createEditor ( ) ; } var deregOnGridScroll = $scope . col . grid . api . core . on . scrollBegin ( $scope , function ( ) { endEdit ( true ) ; $scope . grid . api . edit . raise . afterCellEdit ( $scope . row . entity , $scope . col . colDef , cellModel ( $scope ) , origCellValue ) ; deregOnGridScroll ( ) ; deregOnEndCellEdit ( ) ; deregOnCancelCellEdit ( ) ; } ) ; var deregOnEndCellEdit = $scope . $on ( uiGridEditConstants . events . END_CELL_EDIT , function ( evt , retainFocus ) { endEdit ( retainFocus ) ; $scope . grid . api . edit . raise . afterCellEdit ( $scope . row . entity , $scope . col . colDef , cellModel ( $scope ) , origCellValue ) ; deregOnEndCellEdit ( ) ; deregOnGridScroll ( ) ; deregOnCancelCellEdit ( ) ; } ) ; var deregOnCancelCellEdit = $scope . $on ( uiGridEditConstants . events . CANCEL_CELL_EDIT , function ( ) { cancelEdit ( ) ; deregOnCancelCellEdit ( ) ; deregOnGridScroll ( ) ; deregOnEndCellEdit ( ) ; } ) ; $scope . $broadcast ( uiGridEditConstants . events . BEGIN_CELL_EDIT ) ; $scope . grid . api . edit . raise . beginCellEdit ( $scope . row . entity , $scope . col . colDef ) ; }
@ngdoc property
  @name editDropdownFilter
  @propertyOf ui.grid.edit.api:ColumnDef
  @description A filter that you would like to apply to the values in the options list
  of the dropdown.
@ngdoc property @name editDropdownFilter @propertyOf ui . grid . edit . api : ColumnDef @description A filter that you would like to apply to the values in the options list of the dropdown .
// If we are already editing, then just skip this so we don't try editing twice... //get original value from the cell // case 'number': //   inputType = 'number'; //   break; //stop editing when grid is scrolled //end editing //cancel editing