title: Angular ng-grid - How to remove row after submit in Modal
body: <p>I have a grid of task items loaded by ng-grid that when clicked load more information in a Modal window, of the user clicks Submit then the task is set to inactive in the DB and I need it removed from the Grid.</p>
  
  <p>My Controller:</p>
  
  <pre><code>app.controller('taskController', ['$scope', 'myTasks', 'modalService',
  function($scope, myTasks, modalService) {
      $scope.loading = true;
  
      // Init Grid
      $scope.myData = [];
      $scope.mySelections = [];
      $scope.gridOptions = {
          data: 'myData',
          columnDefs: [{field: 'headline', displayName: 'Headline', cellTemplate:'&lt;div class="ngCellText" ng-class="col.colIndex()"&gt;&lt;a class="selectedItems" ng-click="edit(row)"&gt;{{row.getProperty(col.field)}}&lt;/a&gt;&lt;/div&gt;'},
              {field:'date_assigned', displayName:'Date'}],
          selectedItems: $scope.mySelections,
          multiSelect: false,
          headerRowHeight:0,
          headerCellTemplate: '',
          hideHeaders: true,
          enableRowSelection: true
      };
  
  
  
      // Fetch tasks and populate grid
      $scope.tasks = myTasks.myTasks().then(function(tasks) {
          $scope.myData = tasks;
          $scope.gridOptions = { data: 'myData' }
          $scope.loading = false;
  
  
          // Open model when row clicked
          $scope.edit = function (row, $scope) {
  
              var modalOptions = {
                  closeButtonText: 'Cancel',
                  actionButtonText: 'Update Task',
                  headerText: 'View Task',
                  headlineText: row.entity.headline,
                  messageText: row.entity.message,
                  assignedToText: row.entity.assigned_to_name,
                  assignedByText: row.entity.assigned_by_name,
                  dateAssignedText: row.entity.date_assigned
              };
  
  
              // Open modal with task details
              modalService.showModal({}, modalOptions).then(function (result) {
                  var status = $('#task_status').is(':checked');
                  var message = $('#completed_message').val();
                  var xsrf = $.param({id: row.entity.id, status: status, message: message});
  
                  // Update task and reload grid
                  myTasks.updateTask(xsrf).then(function(row) {
  
                          // Remove item from grid - NOT WORKING HERE
                          var index = this.row.rowIndex;
                          alert(index);
                          $scope.gridOptions.selectItem(index, false);
                          $scope.myData.splice(index, 1);
  
  
  
                  });
              });
          };
  
      });
  }]);
  </code></pre>
  
  <p>UPDATED: To remove item from $scope.myData</p>