title: Altering the class values or styles of cells in ui-grid
body: <p>I have several unique cases inside ui-grid where the cells of certain table contents need additional class, or even style rules assigned, so the appearance for these cells stands out compared to others. Looking through the official ui-grid documentation I found that it could be done with cellTemplate, but I couldn't get any consistent results. What is the best approach here?</p>
  
  <p>Below are the code changes I have attempted before, with the intent being to change the class name based on the returned value from a filter call made</p>
  
  <pre><code>//Define Grid Headings
  $scope.scheduledPatientAppointments = [
          {
              field: 'appointment_date',
              displayName: 'Appointment Date'
          },
          {
              field: 'doctor_name',
              displayName: 'Doctor Name'
          },
          {
              field: 'procedure_type_eng',
              displayName: 'Medical Procedure Type'
          },
          {
              field: 'appointment_status_eng',
              displayName: 'Appointment Status'
          },
          {
              field: 'docs_received',
              displayName: 'Related Documents',
              cellTemplate: '&lt;div class="ui-grid-cell-contents" ng-click="grid.appScope.loadDocumentsModal(\'{{row.entity.id}}\')"&gt;{{grid.getCellValue(row, col) | hasDocuments}}&lt;/div&gt;',
              cellFilter: 'hasDocuments',
              cellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) {
                  if (grid.getCellValue(row, col).toLowerCase() === 'missing') {
                      return 'missing';
                  } else if (grid.getCellValue(row, col).toLowerCase() === 'received') {
                    return 'received';
                  } else {
                    return 'undefined';
                  }
              }
          }
      ];
  
  // Define Grid Options
  $scope.PatientAppointmentsGrid = {
      selectionRowHeaderWidth: 25,
      enableHorizontalScrollbar: false,
      rowHeight: 35,
      enableSorting: true,
      columnDefs: $scope.columnsPatient,
      data: [],
      onRegisterApi: function (gridApi) {
          $scope.gridApi = gridApi;
      }
  };    
  
  //Behavior for patient page load
  $scope.appointmentsProvider = patientsService.patientFactory.getAppointmentsForPatient($stateParams.id).then(
          function successCallback(response) {
              var preFetchData = response.data.data;
              angular.forEach(preFetchData, function (value, key) {documentsService.documentsFactory.getDocumentsByAppointmentId(value.id).then(
                          function successCallback(response2) {
  
                              if (response2.data.length &gt;= 1) {
                                  //Append value state to the preFetchData object (count size)
                                  var totalFiles = response2.data.length;
                                  preFetchData[key].docs_received = totalFiles;
                              } else {
                                  preFetchData[key].docs_received = 0;
                              }
                          }, function errorCallback(response2) {
                      console.debug("Error", response2);
                  });
              });
  
              $scope.PatientAppointmentsGrid.data = preFetchData;
          },
          function errorCallback(response) {
              console.debug("Error", response);
          });
  </code></pre>
  
  <p>The contents from the "Related Documents" are initally set to Missing (the original rest call returns nothing, and the filter call sets it to that. However, a later call actually loads associated documents per row, and I believe the inactivity of the grid on this particular call is what is causing no class to get set here.</p>
  
  <p>Thoughts on the best approach here?</p>