sc_field_style({My_Field}, "Background-Color", "Size", "Color", "Family", "Weight")

The sc_field_style macro allows you to dynamically change the CSS of fields in a Grid application.

Parameters

This macro does not allow the use of variables in the parameters. Therefore, the parameter values (arguments) must be passed directly in the macro, in the correct order.

Only the field_name parameter is mandatory. However, when "skipping" a parameter, it must be passed as an empty string.
For example, to change the third parameter (font-size) without modifying the background color, the macro should be used as follows: sc_field_style({data_nasc}, '', '15px');

Parameter Description Example
field_name This parameter is mandatory and indicates the name of the field to be styled. The field name must be enclosed in curly braces: {field_name}.

sc_field_style({data_nasc}, '#33FF99', '15px', '#000000', 'Arial, sans-serif', 'bold');

background-color Changes the background color of the field cell (column) using the CSS background-color property.

sc_field_style({data_nasc}, '#33FF99');

font-size Uses the font-size property to change the font size of the field. Just provide the desired value, such as '14px'.

sc_field_style({data_nasc}, '', '14px');

color Changes the text color of the field using the CSS color property.

sc_field_style({data_nasc}, '', '', '#33FF99');

font-family Changes the font family of the field, overriding the default font used in the application.

sc_field_style({data_nasc}, '', '', '', 'Arial, sans-serif');

font-weight Changes the font weight (thickness) of the field using the CSS font-weight property.

sc_field_style({data_nasc}, '', '', '', '', 'bold');

Usage examples

Example 1: Expired dates with red background

if ({data_vencimento} < date('Y-m-d')) {
    sc_field_style({data_vencimento}, '#FF4D4D', '', '#FFFFFF');
}

Example 2: Highlight field with larger font

sc_field_style({nome_cliente}, '', '18px');

Example 3: Monospaced font for description

sc_field_style({descricao}, '', '', '', 'Courier New, monospace');

Example 4: Bold text for "Pending" status

if ({status} == 'Pendente') {
    sc_field_style({status}, '', '', '', '', 'bold');
}

Example 5: Visual alert for "Under Review"

if ({status} == 'Em AnĂ¡lise') {
    sc_field_style({status}, '#FFF3CD', '14px', '#856404');
}