Conditional Colors in Editable Grid

How can I change column text color in Editable Grid ?
I.e:

IF ($string1 == “EXPIRED”);
{
Field1 (is RED)
}

Events: onRecord

if ({field_name} == 1 OR {field_name} == 2)
{
sc_field_color (“field_name”, “#00b300”);
}
else
{
sc_field_color (“field_name”, “#ff0000”);
}

I tried this but it does not work. Please note that I’m referring to EDITABLE GRID (not a grid App).

echo’<style>#id_sc_field_dienst_1{background-color: blue;}</style>’;

Thanks for suggestion. So where would you place this code ? in onRecord ?