1

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);
      });
  };
fauverism
  • 1,970
  • 3
  • 33
  • 59

1 Answers1

2

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.

PaulL
  • 6,650
  • 3
  • 35
  • 39
  • 1
    Hmm. That shouldn't be the case - if you call notifyDataChange then it should remove the class immediately (or at least, on the next digest cycle). – PaulL Mar 28 '15 at 01:23
  • You are completely right PaulL. I was wrong. Thanks a million for your help. I deleted the comment that said it was a bug above to avoid confusion for other users. – fauverism Mar 30 '15 at 19:20