ArtiGrid
v1.6

conditional colors in cells and rows

Conditional Colors for Cells and Rows

This example shows how to apply conditional colors to specific cells or entire rows in an ArtiGrid table.

1. Apply Color to a Specific Cell


$grid->CellColor('officeCode', '==', 4, 'red');

This line sets the background color of the

officeCode
column to red when its value is equal to 4.

2. Apply Color to an Entire Row


$grid->RowColor('employeeNumber', '==', 1370, '#8DED79');

This line highlights the entire row with a light green color (

#8DED79
) if the employeeNumber is 1370.

3. Render the Table


$grid->table('employees');
echo $grid->render();

After setting the conditions, you call

render()
to display the table with the conditional formatting applied.

Summary:


<?php
    $grid = new ArtiGrid();
    $grid->table('employees');
    $grid->CellColor('officeCode','==',4,'red');
    $grid->RowColor('employeeNumber','==',1370,'#8DED79');
    echo $grid->render();
?>
employeeNumber lastName firstName extension email officeCode reportsTo jobTitle Actions