angularjsangular-ui-gridng-gridui.bootstrap

Remove cellClass value from ui.grid


I'm using cellClass in ui.grid to add the class of tomato.

        cellClass: function(grid, row, col) {
          if (grid.getCellValue(row,col) === 'confirmed') {
            return 'green';
          }
          else {
            return '';
          }
        }
      },

How can I remove this class? I'm trying but I don't see a way to find the element with the green class so I can remove it.

$scope.confirm = function(rowEntity) {

    confirmService.sendResponse(payload, idPart)
      .success(function(result) {
        if (rowEntity.entity.status.status !== "confirmed") {
               remove 'green';
        }

        console.log('success ', result);
      })
      .error(function(error) {
        console.log('failed ', error);
      });
  };

Solution

  • You shouldn't need to remove it, you need to update the status in the grid to something other than confirmed (perhaps 'saved'), and then call notifyDataChange to tell the grid that you've changed a data value, the grid will then re-evaluate the cell classes.

    The notifyDataChange api is used in http://ui-grid.info/docs/#/tutorial/113_adding_and_removing_columns, amongst other tutorials, and I think the value you want is uiGridConstants.dataChange.EDIT.