Change text color of Data grid cell

Hi everyone,

Can somebody please help. I would like to change the text color of a data grid cell inside OnCellRenderer()

I have tried these things but it did not help:

  1. added args.Attributes.Add("class", "white-text"); to OnCellRenderer and added CSS for white-text to the same component's CSS class and also to the general CSS class but none of them helped. Where should I add that class?

  2. added args.Attributes.Add("style", $"color: {(args.Data.Stop < DateTime.UtcNow ? "white" : "black")} !important;"); problem with this one is that it cannot override the color even with the !important added.
    Screenshot_1

I would like to add all of the style-related changes in one place rather than both on the template and on the code.

Did you ever find a solution to this?

Figured it out

Add a Class Attribute via the CellRender method

 if (args.Data.DueDate<=DateTime.Now)
 {
     args.Attributes.Add("class","condFormat");
 }

and add that class to my custom css file

.condFormat{
color:white;
}

.condFormat .rz-cell-data{
color: inherit !important;
}

saved me adding a template to every column which would have been v time consuming