1

When I'm finished editing a textarea in the grid the edit mode is not closing.

In this Plunker, if you double-click one of the cells under Title, the textarea opens correctly, but does not close after I click out of the cell.

http://plnkr.co/edit/9jrzziWOP6hWWQ1Gab39?p=preview

<div ui-grid="{ data: data, columnDefs: columnDefs }" ui-grid-edit></div>
var app = angular.module('app', ['ui.grid', 'ui.grid.edit']);

app.controller('MainCtrl', ['$scope', function ($scope) {
   $scope.data = [
     { name: 'John', title: 'CEO' },
     { name: 'Jane', title: 'Developer' }
   ];

   $scope.columnDefs = [
     {name: 'name', enableCellEdit: false},
     { name: 'title',
        cellEditableCondition: true,
        enableCellEdit: true,                                
        editType: 'textarea',
        editableCellTemplate: '<textarea rows="4" cols="140" ng-model="MODEL_COL_FIELD"></textarea>'
     }
   ];
 }]);
georgeawg
  • 48,608
  • 13
  • 72
  • 95
tcrafton
  • 97
  • 2
  • 10

1 Answers1

0

Your problem has to do with the line:

editableCellTemplate: '<textarea rows="4" cols="140" ng-model="MODEL_COL_FIELD"></textarea>'

In the API for uiGrid-edit, it states that you must have valid html, templateCache Id, or url that returns html content to be compiled when edit mode is invoked. In your case, you haven't included a means for the textarea to exit edit mode. To remedy this, include ui-grid-editor in the tag as follows.

editableCellTemplate: '<textarea ui-grid-editor rows="4" cols="140" ng-model="MODEL_COL_FIELD"></textarea>'

CoGaMa64
  • 20
  • 2
  • That solves the problem of edit mode not exiting but when I hit Enter to add a new line in the textarea it closes edit mode instead of adding a new line. – tcrafton Oct 01 '19 at 19:26
  • The escape keys are mentioned in the uiGrid documentation above and can't be overridden to my knowledge. The styling of the grid row height would also be a little bit of a nightmare I suspect as each row would have to be dynamic based on the content of the column(s) with textarea. What I would do probably is, instead of using a cellTemplate – CoGaMa64 Oct 01 '19 at 20:13
  • That's a fantastic idea, I'll go that route, thanks for your help. – tcrafton Oct 01 '19 at 20:25