Choose your database:
AnySQL
MySQL
MS SQL Server
PostgreSQL
SQLite
Firebird
Oracle
SQL Anywhere
DB2
MaxDB

Subscribe to our news:
Partners

DB2 PHP Generator online Help

Prev Return to chapter overview Next

OnCustomDrawRow

This event occurs on rendering a grid row. It is an extremely useful event for conditional formatting such as changing font color, font styles, row background color, cell background color, etc. This event (as well as the OnExtendedCustomDrawRow one) is used for conditional formatting. The only difference between these two events is that OnCustomDrawRow has a more understandable parameter list while OnExtendedCustomDrawRow provides more flexible abilities.

 

Signature:

function OnCustomDrawRow ($rowData, &$cellFontColor, &$cellFontSize, &$cellBgColor,

    &$cellItalicAttr, &$cellBoldAttr)

 

Parameters:

$rowData

The associative array of values that corresponds to the currently processed row.

$cellFontColor

The parameter allows to set a font color for selected fields.

$cellFontSize

The parameter defines a font size of selected data.

$cellBgColor

The parameter allows to set a background color of fields.

$cellItalicAttr

Set the parameter to true to represent text in cursive font.

$cellBoldAttr

Set the parameter to true to use bold font.

 

NB. $rowData array keys should contain the real column names in the data source (table, view, or query). Don't use column captions instead!

 

Example 1:

Suppose we need to create a webpage with list of customers with addresses represented in cursive. This column in the data source is named 'address_id' and the column's caption is "Address".

 

To define the font attribute, use the following code:

 

$cellItalicAttr['address_id'] = true;

 

Example 2:

In the example below we need to display winning team score in red and losing team score in black; moreover, both scores should be in bold and displayed by a 16pt font.

 

$cellFontSize['home_team_score'] = '16pt';

$cellBoldAttr['home_team_score'] = true;

 

$cellFontSize['away_team_score'] = '16pt';

$cellBoldAttr['away_team_score'] = true;

 

if ($rowData['home_team_score'] > $rowData['away_team_score'])

  $cellFontColor['home_team_score'] = '#F65317';

else

  $cellFontColor['away_team_score'] = '#000000';



Prev Return to chapter overview Next