You can easily add coloured highlights to your grids in just a couple of minutes using
this library. Click the link below for a demonstration:
The Highlight Cells library allows you to set the colour of any grid
cell based on the content.
In order to use this functionality, you merely add the for segment to
your for, and call the function setting the grid name and the name
of the function you wish to use. This callback function is given the
row, column, cell contents and the grid name. The function merely
returns the colour to set that cell.
This allows you to easily set the colour based on the cell contents,
or you could examine any particular value in the given row, this
enabling you to set the colour for an entire row based on a single
or multiple column values.
Create a
new procedure file and name the
Map Demo Highlight Cells
|
|
And the
folder prefix DHC.
|
|
Select the form and
name it Demo Highlight Cells.
|
|
Set the
colour to Silver.
|
|
Add a grid
to the form and resize
it as shown.
|
|
Set the
table name for the
grid to eFolder
|
|
Select the Columns property
tab.
|
|
Add the
following columns: eFolderName
|
|
ePriority
|
|
eSubject
|
|
Set the
column headings and widths
as shown.
|
|
Go to the Procedure
properties.
|
|
On the
used libraries tab select the Add
button and connect to the
database.
|
|
Select the Highlight Cells
library and press OK.
|
|
Press OK.
|
|
Add a form segment
to the form.
|
|
Select the Highlight
Cells form segment in the
properties.
|
|
Add a new Client
script called Update Grid, set it
to the form, and make sure
Jscript is selected.
|
|
Enter a
function as shown. If
“2” is not
appropriate, replace it with an
appropriate figure.
|
|
Here is the function in
text:
|
function UpdateGrid( iCol, iRow, sCellContents, sGridName )
{
if ( sCellContents == "2" )
return "red";
}
|
In the Do this
property of the form, add a
client extensions statement. Select
“Run a Form Script”
|
|
Select the
HighlightCells function and Jscript
as the language.
|
|
Now edit
the function call to add the
required parameters
as shown.
|
|
Here is the statement
in text:
|
OnLoad=HighlightCells ( "Grid1" , UpdateGrid )&Language=JScript
|
Save the
Procedure as Demo Highlight
Cells and publish.
|
|
Open the
blank form in the Client.
|
|
Notice the cell containing
“2” is highlighted
red.
|
|
Now go to the function
and edit it.
|
|
Replace it with the
shown function.
|
|
Here it is
in text:
|
function UpdateGrid( iCol, iRow, sCellContents, sGridName )
{
if ( eworkGetCell(sGridName, iRow, 1 ) < "9" )
return "green";
}
|
When you
save and publish, you will
see that all rows containing
“2” in column 1 (the
second column) are highlighted
in light red.
|
|